public void CreateWithNullContextThrows() { // Arrange var sut = new ArrayRelay(); var dummyRequest = new object(); // Act & assert Assert.Throws <ArgumentNullException>(() => sut.Create(dummyRequest, null)); }
public void CreateWithNullContextThrows() { // Fixture setup var sut = new ArrayRelay(); var dummyRequest = new object(); // Exercise system and verify outcome Assert.Throws <ArgumentNullException>(() => sut.Create(dummyRequest, null)); // Teardown }
public void CreateWithNoneArrayRequestReturnsCorrectResult(object request) { // Arrange var sut = new ArrayRelay(); // Act var dummyContext = new DelegatingSpecimenContext(); var result = sut.Create(request, dummyContext); // Assert var expectedResult = new NoSpecimen(); Assert.Equal(expectedResult, result); }
public void CreateWithNoneArrayRequestReturnsCorrectResult(object request) { // Fixture setup var sut = new ArrayRelay(); // Exercise system var dummyContext = new DelegatingSpecimenContext(); var result = sut.Create(request, dummyContext); // Verify outcome var expectedResult = new NoSpecimen(); Assert.Equal(expectedResult, result); // Teardown }
public void CreateReturnsCorrectResultWhenContextReturnsNonEnumerableResult(object response) { // Arrange var request = typeof(object[]); var context = new DelegatingSpecimenContext { OnResolve = r => response }; var sut = new ArrayRelay(); // Act var result = sut.Create(request, context); // Assert var expectedResult = new NoSpecimen(); Assert.Equal(expectedResult, result); }
public void CreateWithArrayRequestReturnsCorrectResult(Type request, Type itemType) { // Arrange var expectedRequest = new MultipleRequest(itemType); object expectedResult = Array.CreateInstance(itemType, 0); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen() }; var sut = new ArrayRelay(); // Act var result = sut.Create(request, context); // Assert Assert.Equal(expectedResult, result); }
public void CreateReturnsCorrectResultWhenContextReturnsNonEnumerableResult(object response) { // Fixture setup var request = typeof(object[]); var context = new DelegatingSpecimenContext { OnResolve = r => response }; var sut = new ArrayRelay(); // Exercise system var result = sut.Create(request, context); // Verify outcome var expectedResult = new NoSpecimen(); Assert.Equal(expectedResult, result); // Teardown }
public void CreateWithArrayRequestReturnsCorrectResult(Type request, Type itemType) { // Fixture setup var expectedRequest = new MultipleRequest(itemType); object expectedResult = Array.CreateInstance(itemType, 0); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen() }; var sut = new ArrayRelay(); // Exercise system var result = sut.Create(request, context); // Verify outcome Assert.Equal(expectedResult, result); // Teardown }
public void CreateConvertsEnumerableToArray() { // Arrange var request = typeof(int[]); var expectedRequest = new MultipleRequest(typeof(int)); var enumerable = Enumerable.Range(1, 3); var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? (object)enumerable : new NoSpecimen() }; var sut = new ArrayRelay(); // Act var result = sut.Create(request, context); // Assert var a = Assert.IsAssignableFrom <int[]>(result); Assert.True(enumerable.SequenceEqual(a)); }
public void CreateConvertsEnumerableToArray() { // Fixture setup var request = typeof(int[]); var expectedRequest = new MultipleRequest(typeof(int)); var enumerable = Enumerable.Range(1, 3); #pragma warning disable 618 var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? (object)enumerable : new NoSpecimen(r) }; #pragma warning restore 618 var sut = new ArrayRelay(); // Exercise system var result = sut.Create(request, context); // Verify outcome var a = Assert.IsAssignableFrom <int[]>(result); Assert.True(enumerable.SequenceEqual(a)); // Teardown }