public MockFoozzing <T> Build() { return(new MockFoozzing <T> { _voidVoid = _voidVoid, _responseTaskVoid = _responseTaskVoid, _paramType = _paramType, _paramGeneric = _paramGeneric, _paramTypeResponseTask = _paramTypeResponseTask, _paramTuple = _paramTuple, _paramTypeGeneric = _paramTypeGeneric, _responseGeneric = _responseGeneric, _responseType = _responseType, _responseTaskGeneric = _responseTaskGeneric, _responseTaskType = _responseTaskType, _paramTypeResponseTaskType = _paramTypeResponseTaskType, _paramTupleResponseType = _paramTupleResponseType, _funcTaskGeneric = _funcTaskGeneric, _funcTaskGenericResponseTaskGeneric = _funcTaskGenericResponseTaskGeneric, _sameNameDifParamsInt = _sameNameDifParamsInt, _sameNameDifParamsDouble = _sameNameDifParamsDouble, _actionGenericResponseActionGeneric = _actionGenericResponseActionGeneric, _actionTypeResponseActionType = _actionTypeResponseActionType, , });
public void InvokeTask_ShouldThrowExceptionWithMethodNameIfInvocationNotUpdated() { // Arrange string expected = "expected"; MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName"); // Act Func <Task> actual = async() => await subject.InvokeTask(expected); // Assert actual.Should().ThrowExactly <TestException>().WithMessage("If you want to use methodName, configure via Builder."); }
public void AssertInvokedWith_ShouldThrowWhenNotInvoked() { // Arrange MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName"); subject.UpdateInvocation(); // Act Action actual = () => subject.AssertInvokedWith("expected"); // Assert actual.Should().Throw <Exception>().WithMessage("methodName was expected but not invoked."); }
public void AssertCustom_ShouldNotThrowWhenTrue_WithInvoke() { // Arrange MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName"); subject.UpdateInvocation(); subject.Invoke("expected"); // Act Action actual = () => subject.AssertCustom(o => o.Equals("expected").Should().BeTrue()); // Assert actual.Should().NotThrow(); }
public void AssertCustom_ShouldThrowWhenFalse_WithInvoke() { // Arrange MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName"); subject.UpdateInvocation(); subject.Invoke("Not expected"); // Act Action actual = () => subject.AssertCustom(o => o.Equals("expected").Should().BeTrue("this is expected to throw")); // Assert actual.Should().Throw <Exception>(); }
public void AssertInvokedWith_ShouldThrowWhenFalse_WithInvoke() { // Arrange MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName"); subject.UpdateInvocation(); subject.Invoke("Not expected"); // Act Action actual = () => subject.AssertInvokedWith("expected"); // Assert actual.Should().Throw <Exception>().WithMessage("Expected methodName to be invoked with expected but was actually invoked with Not expected"); }
public async Task AssertInvokedWith_ShouldNotThrowWhenTrue_WithInvokeTask() { // Arrange MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName"); subject.UpdateInvocation(); await subject.InvokeTask("expected"); // Act Action actual = () => subject.AssertInvokedWith("expected"); // Assert actual.Should().NotThrow(); }
public void InvokeTask_ShouldNotThrowExceptionIfInvocationUpdated() { // Arrange string expected = "expected"; MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName"); subject.UpdateInvocation(); // Act Func <Task> actual = async() => await subject.InvokeTask(expected); // Assert actual.Should().NotThrow(); }
public void Invoke_ShouldNotThrowExceptionIfInvocationUpdated() { // Arrange string expected = "expected"; MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName"); subject.UpdateInvocation(); // Act Action actual = () => subject.Invoke(expected); // Assert actual.Should().NotThrow(); }
public void InvokeTask_ShouldThrowExceptionWhenUpdateInvocationSetUpForThat() { // Arrange string expected = "expected"; MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName"); subject.UpdateInvocation(() => throw new Exception("I throw this")); // Act Func <Task> actual = async() => await subject.InvokeTask(expected); // Assert actual.Should().ThrowExactly <Exception>().WithMessage("I throw this"); }
public void InvokeTask_ShouldTrackInvocationWithExceptionThrown() { // Arrange MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName"); subject.UpdateInvocation(() => { }, () => throw new Exception("Second Invocation")); // Act Func <Task> actual = async() => await subject.InvokeTask(""); Func <Task> thrower = async() => await subject.InvokeTask(""); // Assert actual.Should().NotThrow(); thrower.Should().ThrowExactly <Exception>().WithMessage("Second Invocation"); subject.AssertInvokedCountMatches(2); }
public void Invoke_ShouldNotThrowWhenTrueWithMultipleInvokes() { // Arrange MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName"); subject.UpdateInvocation(); // Act Action actual = () => { subject.Invoke("expected"); subject.Invoke("expected"); subject.Invoke("expected"); }; // Assert actual.Should().NotThrow(); }
public void CustomAssert_ShouldAssertInOrderOfInvocation_WithInvoke() { // Arrange string expected1 = "expected1"; string expected2 = "expected2"; MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName"); subject.UpdateInvocation(); subject.Invoke(expected1); subject.Invoke(expected2); // Act Action actual = () => subject.AssertCustom(o => o.Equals(expected1).Should().BeTrue()); Action actual2 = () => subject.AssertCustom(o => o.Equals(expected2).Should().BeTrue()); // Assert actual.Should().NotThrow(); actual2.Should().NotThrow(); }
public async Task AssertInvokedWith_ShouldAssertInOrderOfInvocation_WithInvokeTask() { // Arrange string expected1 = "expected1"; string expected2 = "expected2"; MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName"); subject.UpdateInvocation(); await subject.InvokeTask(expected1); await subject.InvokeTask(expected2); // Act Action actual = () => subject.AssertInvokedWith(expected1); Action actual2 = () => subject.AssertInvokedWith(expected2); // Assert actual.Should().NotThrow(); actual2.Should().NotThrow(); }
public void InvokeTask_ShouldNotThrowWhenTrueWithMultipleInvokes() { // Arrange MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName"); subject.UpdateInvocation(); // Act Func <Task> actual = async() => { await subject.InvokeTask("expected"); await subject.InvokeTask("expected"); await subject.InvokeTask("expected"); }; // Assert actual.Should().NotThrow(); }