コード例 #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();
コード例 #8
0
 public Task <double> ResponseTaskType() => _responseTaskType.InvokeTask();
コード例 #9
0
 public Task <T> ResponseTaskGeneric() => _responseTaskGeneric.InvokeTask();