@@ -12,14 +12,14 @@ public class ObjectComparison
1212 private static Person tsarCopyDifferent = new Person ( "Ivan IV The Kind" , 54 , 170 , 70 , new Person ( "Vasili III of Russia" , 28 , 170 , 60 , null ) ) ;
1313
1414 private static Person person0Parents = new Person ( "1" , 1 , 1 , 1 , null ) ;
15- private static Person person0ParentsCopy = Person . Copy ( person0Parents ) ;
15+ private static Person person0ParentsCopy = person0Parents . Copy ( ) ! ;
1616 private static Person person0ParentsLimits = new Person ( string . Empty , int . MaxValue , int . MinValue , 0 , null ) ;
17- private static Person person0ParentsLimitsCopy = Person . Copy ( person0ParentsLimits ) ;
17+ private static Person person0ParentsLimitsCopy = person0ParentsLimits . Copy ( ) ! ;
1818 private static Person person1Parents = new Person ( "1" , 1 , 1 , 1 , new Person ( "2" , 2 , 2 , 2 , null ) ) ;
19- private static Person person1ParentsСopy = Person . Copy ( person1Parents ) ;
19+ private static Person person1ParentsСopy = person1Parents . Copy ( ) ! ;
2020 private static Person person1ParentsDifferent = new Person ( "1" , 1 , 1 , 1 , new Person ( "3" , 3 , 3 , 3 , null ) ) ;
2121 private static Person person2Parents = new Person ( "1" , 1 , 1 , 1 , new Person ( "2" , 2 , 2 , 2 , new Person ( "3" , 3 , 3 , 3 , null ) ) ) ;
22- private static Person person2ParentsCopy = Person . Copy ( person2Parents ) ;
22+ private static Person person2ParentsCopy = person2Parents . Copy ( ) ! ;
2323 private static Person person2ParentsDifferent = new Person ( "1" , 1 , 1 , 1 , new Person ( "2" , 2 , 2 , 2 , new Person ( "5" , 5 , 5 , 5 , null ) ) ) ;
2424 #endregion
2525
@@ -81,27 +81,7 @@ public void AreEqual_NotThrows_OnEqualPersons(Person? actual, Person? expected)
8181 actual . Should ( ) . BeEquivalentTo ( expected , options =>
8282 options
8383 . Excluding ( t => t . Id )
84- . Using < Person > ( ctx =>
85- {
86- AreEqual_NotThrows_OnEqualFields ( ctx . Subject , ctx . Expectation ) ;
87- if ( ctx . Subject != null && ctx . Expectation != null )
88- {
89- if ( ctx . Subject . Parent != null && ctx . Expectation . Parent != null )
90- {
91- AreEqual_NotThrows_OnEqualPersons ( ctx . Subject . Parent , ctx . Expectation . Parent ) ;
92- }
93- else
94- {
95- ctx . Subject . Parent . Should ( ) . BeEquivalentTo ( ctx . Expectation . Parent , options =>
96- options
97- . Excluding ( t => t . Id )
98- . Excluding ( t => t . Parent )
99- ) ;
100- }
101- }
102- }
103- )
104- . WhenTypeIs < Person > ( )
84+ . Excluding ( t => t . Path . EndsWith ( "Id" ) )
10585 ) ;
10686 }
10787
@@ -122,27 +102,11 @@ public void AreEqual_Throw_OnDifferentPersons(Person? actual, Person? expected)
122102 actual . Should ( ) . NotBeEquivalentTo ( expected , options =>
123103 options
124104 . Excluding ( t => t . Id )
125- . Using < Person > ( ctx =>
126- {
127- AreEqual_NotThrows_OnEqualFields ( ctx . Subject , ctx . Expectation ) ;
128- if ( ctx . Subject != null && ctx . Expectation != null )
129- {
130- if ( ctx . Subject . Parent != null && ctx . Expectation . Parent != null )
131- {
132- AreEqual_NotThrows_OnEqualPersons ( ctx . Subject . Parent , ctx . Expectation . Parent ) ;
133- }
134- else
135- {
136- ( ctx . Subject . Parent == null && ctx . Expectation . Parent == null ) . Should ( ) . BeTrue ( ) ;
137- }
138- }
139- }
140- )
141- . WhenTypeIs < Person > ( )
105+ . Excluding ( t => t . Path . EndsWith ( "Id" ) )
142106 ) ;
143107 }
144108
145- //Как будто бы если оставлять обобщенный метод кода становится меньше
109+ // А что так можно было что ли?
146110
147111 // При добавлении новых полей в Person придется расширять условие в return еще больше;
148112 // Тест должен пройти по всем Parent прежде чем дать результат,
0 commit comments