1
- using Microsoft . VisualStudio . TestTools . UnitTesting ;
1
+ using System ;
2
+ using Microsoft . VisualStudio . TestTools . UnitTesting ;
2
3
using ObjectFiller . Test . TestPoco . Library ;
3
4
using Tynamix . ObjectFiller ;
4
5
@@ -10,10 +11,10 @@ public class LibraryFillingTest
10
11
[ TestMethod ]
11
12
public void TestFillLibraryWithSimpleTypes ( )
12
13
{
13
- ObjectFiller < LibraryConstructorWithSimple > lib = new ObjectFiller < LibraryConstructorWithSimple > ( ) ;
14
+ Filler < LibraryConstructorWithSimple > lib = new Filler < LibraryConstructorWithSimple > ( ) ;
14
15
lib . Setup ( )
15
- . IgnoreProperties ( x => x . Books ) ;
16
- LibraryConstructorWithSimple filledLib = lib . Fill ( ) ;
16
+ . OnProperty ( x => x . Books ) . IgnoreIt ( ) ;
17
+ LibraryConstructorWithSimple filledLib = lib . Create ( ) ;
17
18
18
19
Assert . IsNull ( filledLib . Books ) ;
19
20
Assert . IsNotNull ( filledLib ) ;
@@ -24,12 +25,12 @@ public void TestFillLibraryWithSimpleTypes()
24
25
[ TestMethod ]
25
26
public void TestFillLibraryWithListOfBooks ( )
26
27
{
27
- ObjectFiller < LibraryConstructorList > lib = new ObjectFiller < LibraryConstructorList > ( ) ;
28
+ Filler < LibraryConstructorList > lib = new Filler < LibraryConstructorList > ( ) ;
28
29
lib . Setup ( )
29
- . IgnoreProperties ( x => x . Books , x => x . Name ) ;
30
+ . OnProperty ( x => x . Books ) . IgnoreIt ( )
31
+ . OnProperty ( x => x . Name ) . IgnoreIt ( ) ;
30
32
31
-
32
- LibraryConstructorList filledLib = lib . Fill ( ) ;
33
+ LibraryConstructorList filledLib = lib . Create ( ) ;
33
34
34
35
Assert . IsNotNull ( filledLib ) ;
35
36
Assert . IsNotNull ( filledLib . Books ) ;
@@ -39,54 +40,74 @@ public void TestFillLibraryWithListOfBooks()
39
40
[ TestMethod ]
40
41
public void TestFillLibraryWithListOfIBooks ( )
41
42
{
42
- ObjectFiller < LibraryConstructorList > lib = new ObjectFiller < LibraryConstructorList > ( ) ;
43
+ Filler < LibraryConstructorList > lib = new Filler < LibraryConstructorList > ( ) ;
43
44
lib . Setup ( )
44
- . IgnoreProperties ( x => x . Books )
45
- . RegisterInterface < IBook , Book > ( ) ;
45
+ . OnProperty ( x => x . Books ) . IgnoreIt ( )
46
+ . OnType < IBook > ( ) . CreateInstanceOf < Book > ( ) ;
46
47
47
- LibraryConstructorList filledLib = lib . Fill ( ) ;
48
+ LibraryConstructorList filledLib = lib . Create ( ) ;
48
49
49
50
Assert . IsNotNull ( filledLib . Books ) ;
50
51
}
51
52
52
53
[ TestMethod ]
53
54
public void TestFillLibraryWithPocoOfABook ( )
54
55
{
55
- ObjectFiller < LibraryConstructorPoco > lib = new ObjectFiller < LibraryConstructorPoco > ( ) ;
56
+ Filler < LibraryConstructorPoco > lib = new Filler < LibraryConstructorPoco > ( ) ;
56
57
lib . Setup ( )
57
- . IgnoreProperties ( x => x . Books ) ;
58
-
58
+ . OnProperty ( x => x . Books ) . IgnoreIt ( ) ;
59
59
60
- LibraryConstructorPoco filledLib = lib . Fill ( ) ;
60
+ LibraryConstructorPoco filledLib = lib . Create ( ) ;
61
61
Assert . IsNotNull ( filledLib . Books ) ;
62
62
Assert . AreEqual ( 1 , filledLib . Books . Count ) ;
63
63
}
64
64
65
65
[ TestMethod ]
66
66
public void TestFillLibraryWithDictionary ( )
67
67
{
68
- ObjectFiller < LibraryConstructorDictionary > lib = new ObjectFiller < LibraryConstructorDictionary > ( ) ;
68
+ Filler < LibraryConstructorDictionary > lib = new Filler < LibraryConstructorDictionary > ( ) ;
69
69
lib . Setup ( )
70
- . RegisterInterface < IBook , Book > ( )
71
- . IgnoreProperties ( x => x . Books ) ;
72
-
70
+ . OnType < IBook > ( ) . CreateInstanceOf < Book > ( )
71
+ . OnProperty ( x => x . Books ) . IgnoreIt ( ) ;
73
72
74
- LibraryConstructorDictionary filledLib = lib . Fill ( ) ;
73
+ LibraryConstructorDictionary filledLib = lib . Create ( ) ;
75
74
Assert . IsNotNull ( filledLib . Books ) ;
76
75
}
77
76
78
77
[ TestMethod ]
79
78
public void TestFillLibraryWithDictionaryAndPoco ( )
80
79
{
81
- ObjectFiller < LibraryConstructorDictionary > lib = new ObjectFiller < LibraryConstructorDictionary > ( ) ;
80
+ Filler < LibraryConstructorDictionary > lib = new Filler < LibraryConstructorDictionary > ( ) ;
82
81
lib . Setup ( )
83
- . IgnoreProperties ( x => x . Books , x => x . Name ) ;
82
+ . OnProperty ( x => x . Books ) . IgnoreIt ( )
83
+ . OnProperty ( x => x . Name ) . IgnoreIt ( ) ;
84
84
85
85
86
- LibraryConstructorDictionary filledLib = lib . Fill ( ) ;
86
+ LibraryConstructorDictionary filledLib = lib . Create ( ) ;
87
87
Assert . IsNotNull ( filledLib . Books ) ;
88
88
Assert . IsNotNull ( filledLib . Name ) ;
89
89
90
90
}
91
+
92
+
93
+ public class Person
94
+ {
95
+ public string Name { get ; set ; }
96
+ public string LastName { get ; set ; }
97
+ public int Age { get ; set ; }
98
+ public DateTime Birthday { get ; set ; }
99
+ }
100
+
101
+ public class HelloFiller
102
+ {
103
+ public void FillPerson ( )
104
+ {
105
+ Person person = new Person ( ) ;
106
+
107
+ Filler < Person > pFiller = new Filler < Person > ( ) ;
108
+ Person p = pFiller . Fill ( person ) ;
109
+ }
110
+ }
111
+
91
112
}
92
- }
113
+ }
0 commit comments