1
- using System . Collections ;
2
- using System . Collections . Generic ;
3
- using System . ComponentModel ;
4
- using NUnit . Framework ;
1
+ using NUnit . Framework ;
5
2
6
3
namespace Archetype . Tests
7
4
{
8
- public class NotifyPropertyChangedModule : INotifyPropertyChanged
5
+ public class Animal
9
6
{
10
- public event PropertyChangedEventHandler PropertyChanged ;
11
-
12
- protected virtual void OnPropertyChanged ( string propertyName )
7
+ public virtual string Name
13
8
{
14
- PropertyChangedEventHandler handler = PropertyChanged ;
15
- if ( handler != null ) handler ( this , new PropertyChangedEventArgs ( propertyName ) ) ;
9
+ get { return GetType ( ) . Name ; }
16
10
}
17
11
}
18
12
19
- public class Animal
20
- {
21
- public virtual string Name { get { return GetType ( ) . Name ; } }
22
- }
23
-
24
13
public class Cat : Animal
25
14
{
26
- public string Noise { get { return "Meow" ; } }
15
+ public string Noise
16
+ {
17
+ get { return "Meow" ; }
18
+ }
27
19
}
28
20
29
21
public class CheshireCat : DelegatingPrototype
30
22
{
31
23
public CheshireCat ( Cat cat = null ) : base ( cat )
32
- {
24
+ {
33
25
}
34
26
35
- public string Action { get { return "Grin" ; } }
27
+ public string Action
28
+ {
29
+ get { return "Grin" ; }
30
+ }
36
31
}
37
32
38
33
[ TestFixture ]
39
34
public class ModuleTestsForGetMember
40
35
{
41
- [ Test ]
42
- public void GettingAPropertyThatIsDefinedInTheRootObjectReturnsItsValueWhenThereIsNoPrototype ( )
36
+ [ Test ]
37
+ public void GettingAPropertyThatIsDefinedInTheRootObjectReturnsItsValue ( )
43
38
{
44
- dynamic value = new CheshireCat ( ) ;
39
+ dynamic value = new CheshireCat ( new Cat ( ) ) ;
45
40
Assert . AreEqual ( "Grin" , value . Action ) ;
46
41
}
42
+
47
43
[ Test ]
48
- public void GettingAPropertyThatIsDefinedInTheRootObjectReturnsItsValue ( )
44
+ public void GettingAPropertyThatIsDefinedInTheRootObjectReturnsItsValueWhenThereIsNoPrototype ( )
49
45
{
50
- dynamic value = new CheshireCat ( new Cat ( ) ) ;
46
+ dynamic value = new CheshireCat ( ) ;
51
47
Assert . AreEqual ( "Grin" , value . Action ) ;
52
48
}
49
+
53
50
[ Test ]
54
- public void GettingAPropertyThatIsNotDefinedInTheRootObjectReturnsItsValueIfItIsOnTheLastModule ( )
51
+ public void GettingAPropertyThatIsNotDefinedInTheRootObjectReturnsItsValueAndIsReturnedBottomUp ( )
55
52
{
56
53
dynamic value = new CheshireCat ( new Cat ( ) ) ;
57
- Assert . AreEqual ( "Cat" , value . Name ) ;
54
+ value . Prototypes . Add ( new Animal ( ) ) ;
55
+ Assert . AreEqual ( "Animal" , value . Name ) ;
58
56
}
57
+
59
58
[ Test ]
60
59
public void GettingAPropertyThatIsNotDefinedInTheRootObjectReturnsItsValueIfItIsNotOnTheLastModule ( )
61
60
{
@@ -64,11 +63,10 @@ public void GettingAPropertyThatIsNotDefinedInTheRootObjectReturnsItsValueIfItIs
64
63
}
65
64
66
65
[ Test ]
67
- public void GettingAPropertyThatIsNotDefinedInTheRootObjectReturnsItsValueAndIsReturnedBottomUp ( )
66
+ public void GettingAPropertyThatIsNotDefinedInTheRootObjectReturnsItsValueIfItIsOnTheLastModule ( )
68
67
{
69
68
dynamic value = new CheshireCat ( new Cat ( ) ) ;
70
- value . Prototypes . Add ( new Animal ( ) ) ;
71
- Assert . AreEqual ( "Animal" , value . Name ) ;
69
+ Assert . AreEqual ( "Cat" , value . Name ) ;
72
70
}
73
71
}
74
- }
72
+ }
0 commit comments