public void SutIsSpecimenBuilder() { // Fixture setup // Exercise system var sut = new ParameterRequestRelay(); // Verify outcome Assert.IsAssignableFrom<ISpecimenBuilder>(sut); // Teardown }
public void CreateWithNullContainerWillThrow() { // Fixture setup var sut = new ParameterRequestRelay(); var dummyRequest = new object(); // Exercise system and verify outcome Assert.Throws<ArgumentNullException>(() => sut.Create(dummyRequest, null)); // Teardown }
public void CreateWithNullRequestWillReturnCorrectResult() { // Fixture setup var sut = new ParameterRequestRelay(); // Exercise system var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(null, dummyContainer); // Verify outcome var expectedResult = new NoSpecimen(); Assert.Equal(expectedResult, result); // Teardown }
public void CreateFromParameterRequestWillReturnCorrectResultWhenContainerCanSatisfyRequest() { // Fixture setup var expectedSpecimen = new object(); var parameterInfo = typeof(SingleParameterType<string>).GetConstructors().First().GetParameters().First(); var container = new DelegatingSpecimenContext { OnResolve = r => expectedSpecimen }; var sut = new ParameterRequestRelay(); // Exercise system var result = sut.Create(parameterInfo, container); // Verify outcome Assert.Equal(expectedSpecimen, result); // Teardown }
public void CreateFromNonParameterRequestWillReturnCorrectResult() { // Fixture setup var nonParameterRequest = new object(); var sut = new ParameterRequestRelay(); // Exercise system var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(nonParameterRequest, dummyContainer); // Verify outcome #pragma warning disable 618 var expectedResult = new NoSpecimen(nonParameterRequest); #pragma warning restore 618 Assert.Equal(expectedResult, result); // Teardown }
public void CreateFromParameterRequestWillReturnNullWhenContainerCannotSatisfyRequest() { // Fixture setup var parameterInfo = typeof(SingleParameterType<string>).GetConstructors().First().GetParameters().First(); #pragma warning disable 618 var container = new DelegatingSpecimenContext { OnResolve = r => new NoSpecimen(parameterInfo) }; #pragma warning restore 618 var sut = new ParameterRequestRelay(); // Exercise system var result = sut.Create(parameterInfo, container); // Verify outcome #pragma warning disable 618 var expectedResult = new NoSpecimen(parameterInfo); #pragma warning restore 618 Assert.Equal(expectedResult, result); // Teardown }
public void CreateFromParameterRequestWillCorrectlyInvokeContainer() { // Fixture setup var sut = new ParameterRequestRelay(); var parameterInfo = typeof(SingleParameterType<string>).GetConstructors().First().GetParameters().First(); var expectedRequest = new SeededRequest(parameterInfo.ParameterType, parameterInfo.Name); var mockVerified = false; var containerMock = new DelegatingSpecimenContext(); containerMock.OnResolve = r => { Assert.Equal(expectedRequest, r); mockVerified = true; return null; }; // Exercise system sut.Create(parameterInfo, containerMock); // Verify outcome Assert.True(mockVerified, "Mock verification"); // Teardown }
public ParameterRequestRelay( Ploeh.AutoFixture.Kernel.ParameterRequestRelay inner ) { this.inner = inner; }