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."); }
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); }
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); }
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); }
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"); }
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); }
public Task <TResponse> InvokeTask() => _invokeTask.InvokeTask();
public Task <double> ResponseTaskType() => _responseTaskType.InvokeTask();
public Task <T> ResponseTaskGeneric() => _responseTaskGeneric.InvokeTask();