예제 #1
0
        public void InvokeTask_ShouldThrowExceptionWithMethodNameIfInvocationNotUpdated()
        {
            // Arrange
            MockMethodWithResponse <string> subject = new MockMethodWithResponse <string>("methodName");

            // Act
            Func <Task <string> > actual = async() => await subject.InvokeTask();

            // Assert
            actual.Should().ThrowExactly <TestException>().WithMessage("If you want to use methodName, configure via Builder.");
        }
예제 #2
0
        public async Task InvokeTask_ShouldReturnSameValueWhenInvokedMultipleTimesAndSetupWithOneResponse()
        {
            // Arrange
            string expected = "result";
            MockMethodWithResponse <string> subject = new MockMethodWithResponse <string>("methodName");

            subject.UpdateInvocation(expected);

            // Act
            string actual1 = await subject.InvokeTask();

            string actual2 = await subject.InvokeTask();

            string actual3 = await subject.InvokeTask();


            // Assert
            actual1.Should().Be(expected);
            actual2.Should().Be(expected);
            actual3.Should().Be(expected);
        }
예제 #3
0
        public async Task InvokeTask_ShouldReturnValuesInOrderPassedIntoUpdateInvocationWhenInvokedMultipleTimes()
        {
            // Arrange
            string expected1 = "result1";
            string expected2 = "result2";
            string expected3 = "result3";
            MockMethodWithResponse <string> subject = new MockMethodWithResponse <string>("methodName");

            subject.UpdateInvocation(expected1, expected2, expected3);

            // Act
            string actual1 = await subject.InvokeTask();

            string actual2 = await subject.InvokeTask();

            string actual3 = await subject.InvokeTask();

            // Assert
            actual1.Should().Be(expected1);
            actual2.Should().Be(expected2);
            actual3.Should().Be(expected3);
        }
예제 #4
0
        public void InvokeTask_ShouldTrackInvocationWithExceptionThrown()
        {
            // Arrange
            MockMethodWithResponse <string> subject = new MockMethodWithResponse <string>("methodName");

            subject.UpdateInvocation(() => throw new Exception("Second Invocation"));

            // Act
            Func <Task> actual = async() => await subject.InvokeTask();

            // Assert
            actual.Should().Throw <Exception>();
            subject.AssertInvokedCountMatches(1);
        }
예제 #5
0
        public void InvokeTask_ShouldThrowExceptionWhenUpdateInvocationSetUpForThat()
        {
            // Arrange
            MockMethodWithResponse <string> subject = new MockMethodWithResponse <string>("methodName");


            subject.UpdateInvocation(() => throw new Exception("I throw this"));

            // Act
            Func <Task <string> > actual = async() => await subject.InvokeTask();

            // Assert
            actual.Should().ThrowExactly <Exception>().WithMessage("I throw this");
        }
예제 #6
0
        public async Task InvokeTask_ShouldReturnValuePassedIntoUpdateInvocation()
        {
            // Arrange
            string expected = "result";
            MockMethodWithResponse <string> subject = new MockMethodWithResponse <string>("methodName");

            subject.UpdateInvocation(expected);

            // Act
            string actual = await subject.InvokeTask();

            // Assert
            actual.Should().Be(expected);
        }
예제 #7
0
 public Task <TResponse> InvokeTask() => _invokeTask.InvokeTask();
 public Task <double> ResponseTaskType() => _responseTaskType.InvokeTask();
 public Task <T> ResponseTaskGeneric() => _responseTaskGeneric.InvokeTask();