public void CreateWithNullContainerThrowsArgumentNullException() { // Fixture setup var dummyRequest = new object(); var sut = new DelegateGenerator(); // Exercise system and verify outcome Assert.Throws(typeof(ArgumentNullException), () => sut.Create(dummyRequest, null)); // Teardown }
public void CreateWithNullRequestReturnsNoSpecimen() { // Fixture setup var sut = new DelegateGenerator(); // Exercise system var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(null, dummyContainer); // Verify outcome Assert.Equal(new NoSpecimen(), result); // Teardown }
public void CreateWithVoidSingleObjectParameterDelegateRequestReturnsCorrectResult() { // Fixture setup var delegateRequest = typeof(Action<object>); var sut = new DelegateGenerator(); // Exercise system var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(delegateRequest, dummyContainer); // Verify outcome Assert.IsType<Action<object>>(result); // Teardown }
public void CreateWithNonDelegateRequestReturnsNoSpecimen() { // Fixture setup var nonDelegateRequest = new object(); var sut = new DelegateGenerator(); // Exercise system var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(nonDelegateRequest, dummyContainer); // Verify outcome var expectedResult = new NoSpecimen(nonDelegateRequest); Assert.Equal(expectedResult, result); // Teardown }
public void CreateWithReturnValueParameterlessDelegateRequestReturnsDelegateReturningValueSpecimen() { // Fixture setup var delegateRequest = typeof(Func<int>); var expectedResult = 3; var sut = new DelegateGenerator(); // Exercise system var dummyContainer = new DelegatingSpecimenContext { OnResolve = arg => expectedResult }; var result = sut.Create(delegateRequest, dummyContainer); // Verify outcome var actualResult = ((Func<int>)result).Invoke(); Assert.Equal(expectedResult, actualResult); // Teardown }
public void CreateWithReturnValueParameterlessDelegateRequestReturnsCorrectResult() { // Fixture setup var delegateRequest = typeof(Func<int>); var sut = new DelegateGenerator(); // Exercise system var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(delegateRequest, dummyContainer); // Verify outcome Assert.IsType<Func<int>>(result); // Teardown }
public void CreateWithVoidParameterlessDelegateRequestReturnsDelegateNotThrowing() { // Fixture setup var delegateRequest = typeof(Action); var sut = new DelegateGenerator(); // Exercise system var dummyContainer = new DelegatingSpecimenContext(); var result = sut.Create(delegateRequest, dummyContainer); // Verify outcome Assert.DoesNotThrow(() => ((Action)result).Invoke()); // Teardown }