33using System . Linq . Expressions ;
44using NotSoAutoMapper . Tests . TestExtensions ;
55using Microsoft . VisualStudio . TestTools . UnitTesting ;
6- using NSubstitute ;
7- using NSubstitute . ReceivedExtensions ;
86
97namespace NotSoAutoMapper . Tests
108{
@@ -189,41 +187,11 @@ public void Merge_MergesExpressionWithExtension()
189187 Expression < Func < Thing , ThingDto > > expression = x => new ThingDto { Id = x . Id } ;
190188 Expression < Func < Thing , ThingDto > > extension = x => new ThingDto { Name = x . Name } ;
191189 var expectedExpression = expression . Merge ( extension ) ;
192- var mapper = CreateMapperSubstitute ( expression ) ;
190+ var mapper = new Mapper < Thing , ThingDto > ( expression ) ;
193191
194192 var result = mapper . Merge ( extension ) ;
195-
196- _ = mapper . Received ( Quantity . AtLeastOne ( ) ) . Expression ; // Only the Expression should get used.
193+
197194 Assert . That . ExpressionsAreEqual ( expectedExpression , result . Expression ) ;
198195 }
199-
200- [ TestMethod ]
201- public void MergeOriginal_MergesOriginalExpressionWithExtension ( )
202- {
203- Expression < Func < Thing , ThingDto > > expression = x => new ThingDto ( ) ;
204- Expression < Func < Thing , ThingDto > > originalExpression = x => new ThingDto { Id = x . Id } ;
205- Expression < Func < Thing , ThingDto > > extension = x => new ThingDto { Name = x . Name } ;
206- var expectedExpression = originalExpression . Merge ( extension ) ;
207- var mapper = CreateMapperSubstitute ( expression , originalExpression ) ;
208-
209- var result = mapper . MergeOriginal ( extension ) ;
210-
211- _ = mapper . Received ( Quantity . AtLeastOne ( ) )
212- . OriginalExpression ; // Only the OriginalExpression should get used.
213- Assert . That . ExpressionsAreEqual ( expectedExpression , result . OriginalExpression ) ;
214- }
215-
216- private static IMapper < TInput , TResult > CreateMapperSubstitute < TInput , TResult > (
217- Expression < Func < TInput , TResult > > expression , Expression < Func < TInput , TResult > > ? originalExpression = null )
218- where TInput : notnull
219- where TResult : notnull
220- {
221- var mapper = Substitute . For < IMapper < TInput , TResult > > ( ) ;
222- mapper . OriginalExpression . Returns ( originalExpression ?? expression ) ;
223- mapper . Expression . Returns ( expression ) ;
224- mapper . WithExpression ( Arg . Any < Expression < Func < TInput , TResult > > > ( ) )
225- . Returns ( call => CreateMapperSubstitute ( call . Arg < Expression < Func < TInput , TResult > > > ( ) ) ) ;
226- return mapper ;
227- }
228196 }
229197}
0 commit comments