2
require 'soap/baseData'
9
class TestSOAPElement < Test::Unit::TestCase
20
def d(elename = nil, text = nil)
21
elename ||= n(nil, nil)
23
SOAPElement.new(elename, text)
25
SOAPElement.new(elename) # do not merge.
29
def n(namespace, name)
30
XSD::QName.new(namespace, name)
36
assert_equal(elename, obj.elename)
37
assert_equal(LiteralNamespace, obj.encodingstyle)
38
assert_equal({}, obj.extraattr)
39
assert_equal([], obj.precedents)
40
assert_equal(nil, obj.qualified)
41
assert_equal(nil, obj.text)
42
assert(obj.members.empty?)
44
obj = d("foo", "text")
45
assert_equal(n(nil, "foo"), obj.elename)
46
assert_equal("text", obj.text)
53
assert(obj.key?("abc"))
54
assert_same(child, obj["abc"])
55
assert_same(child, obj.abc)
59
assert_equal(1, obj.foo)
60
assert_equal(child, obj.var_foo)
63
assert_equal(child, obj.__send__('_?a?b_'))
72
assert(obj.key?("c1"))
73
assert(obj.key?("c2"))
74
assert_equal(c1, obj["c1"])
75
assert_equal(c2, obj["c2"])
78
assert(obj.key?("c2"))
79
assert_equal(c22, obj["c2"])
80
assert_equal(["c1", "c2"], obj.members.sort)
82
k_expect = ["c1", "c2"]
85
assert(k_expect.include?(k))
86
assert(v_expect.include?(v))
90
assert(k_expect.empty?)
91
assert(v_expect.empty?)
102
assert_equal({ "ct1" => "t1", "c2" => { "ct2" => "t2" }}, obj.to_obj)
104
assert_equal(nil, d().to_obj)
105
assert_equal("abc", d(nil, "abc").to_obj)
106
assert_equal(nil, d("abc", nil).to_obj)
110
source = { "ct1" => "t1", "c2" => { "ct2" => "t2" }}
111
assert_equal(source, SOAPElement.from_obj(source).to_obj)
112
source = { "1" => nil }
113
assert_equal(source, SOAPElement.from_obj(source).to_obj)
115
assert_equal(nil, SOAPElement.from_obj(source).to_obj) # not {}
117
assert_equal(nil, SOAPElement.from_obj(source).to_obj)