public void CreateWithNullContextThrows() { var sut = new EnumeratorRelay(); var dummyRequest = new object(); Assert.Throws <ArgumentNullException>(() => sut.Create(dummyRequest, null)); }
public void CreateWithNoEnumeratorRequestReturnsCorrectResult( object request) { var sut = new EnumeratorRelay(); var dummyContext = new DelegatingSpecimenContext(); var result = sut.Create(request, dummyContext); var expectedResult = new NoSpecimen(request); Assert.Equal(expectedResult, result); }
public void CreateReturnsCorrectResultWhenContextReturnsNonEnumerableResult( object response) { var request = typeof(IEnumerator <object>); var context = new DelegatingSpecimenContext { OnResolve = r => response }; var sut = new EnumeratorRelay(); var result = sut.Create(request, context); var expectedResult = new NoSpecimen(request); Assert.Equal(expectedResult, result); }
public void CreateWithEnumeratorRequestReturnsCorrectResult( Type request, Type itemType) { var expectedRequest = typeof(IEnumerable <>).MakeGenericType(itemType); var enumerable = (IList)Activator.CreateInstance( typeof(List <>).MakeGenericType(itemType)); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? (object)enumerable : new NoSpecimen(r) }; var sut = new EnumeratorRelay(); var result = sut.Create(request, context); var expectedResult = enumerable.GetEnumerator(); Assert.Equal(expectedResult, result); }