This repository has been archived by the owner on Dec 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
test_component.rb
80 lines (61 loc) · 1.68 KB
/
test_component.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
require 'test/unit'
$LOAD_PATH.unshift "../lib"
module Wee; end
require 'wee/presenter'
require 'wee/component'
require 'wee/decoration'
require 'wee/holder'
# Mock
class Wee::Session
def self.current
@session ||= new
end
def register_object_for_backtracking(obj)
#p obj
end
end
class TC_Component < Test::Unit::TestCase
def test_add_remove_one_decoration
c = Wee::Component.new
d = Wee::Decoration.new
assert_same c, c.decoration
assert_nil d.owner
c.add_decoration(d)
assert_same d, c.decoration
assert_same c, d.owner
assert_same d, d.owner.decoration
assert_same d, c.remove_decoration(d)
assert_same c, c.decoration
assert_nil d.owner
end
def test_add_remove_multiple_decorations
c = Wee::Component.new
d1 = Wee::Decoration.new
d2 = Wee::Decoration.new
d3 = Wee::Decoration.new
c.add_decoration(d1)
c.add_decoration(d2)
c.add_decoration(d3)
assert_same d3, c.decoration
assert_same d2, d3.owner
assert_same d1, d2.owner
assert_same c, d1.owner
assert_same d2, c.remove_decoration(d2)
assert_same d3, c.decoration
assert_same d1, d3.owner
assert_nil d2.owner
assert_same c, d1.owner
assert_same d1, c.remove_decoration(d1)
assert_same d3, c.decoration
assert_same c, d3.owner
assert_nil d1.owner
# try to remove an already removed decoration
assert_nil c.remove_decoration(d2)
assert_nil c.remove_decoration(d1)
assert_same d3, c.remove_decoration(d3)
assert_same c, c.decoration
assert_nil d3.owner
# TODO: teste, wenn man zuerst die erste decoration löscht
# TODO: Circular references and CC's
end
end