public void AssertInvokedWith_ShouldNotThrowWhenTrue_WithInvoke()
        {
            // Arrange
            MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName");

            subject.UpdateInvocation();
            subject.Invoke("expected");

            // Act
            Action actual = () => subject.AssertInvokedWith("expected");

            // Assert
            actual.Should().NotThrow();
        }
        public async Task AssertCustom_ShouldThrowWhenFalse_WithInvokeTask()
        {
            // Arrange
            MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName");

            subject.UpdateInvocation();
            await subject.InvokeTask("Not expected");

            // Act
            Action actual = () => subject.AssertCustom(o => o.Equals("expected").Should().BeTrue("this is expected to throw"));

            // Assert
            actual.Should().Throw <Exception>();
        }
        public async Task AssertCustom_ShouldNotThrowWhenTrue_WithInvokeTask()
        {
            // Arrange
            MockMethodWithParam <string> subject = new MockMethodWithParam <string>("methodName");

            subject.UpdateInvocation();
            await subject.InvokeTask("expected");

            // Act
            Action actual = () => subject.AssertCustom(o => o.Equals("expected").Should().BeTrue());

            // 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_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 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 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();
        }
 public Builder AssertInvokedWith()
 {
     _assertInvokedWithItem.UpdateInvocation();
     return(this);
 }
 public Builder ParamTuple()
 {
     _paramTuple.UpdateInvocation();
     return(this);
 }
 public Builder ParamTypeGeneric()
 {
     _paramTypeGeneric.UpdateInvocation();
     return(this);
 }
Exemple #15
0
 public Builder UpdateInvocationWithTResponse()
 {
     _updateInvocationTResponseItem.UpdateInvocation();
     return(this);
 }
Exemple #16
0
 public Builder UpdateInvocationWithFunc()
 {
     _updateInvocationFuncItem.UpdateInvocation();
     return(this);
 }
 public Builder ParamTypeResponseTask()
 {
     _paramTypeResponseTask.UpdateInvocation();
     return(this);
 }
 public Builder AssertCustom()
 {
     _assertCustomItem.UpdateInvocation();
     return(this);
 }
Exemple #19
0
 public Builder ShowAlert()
 {
     _showAlert.UpdateInvocation();
     return(this);
 }
Exemple #20
0
 public Builder Write()
 {
     _write.UpdateInvocation();
     return(this);
 }
 public Builder Act()
 {
     _act.UpdateInvocation();
     return(this);
 }
 public Builder Invoke()
 {
     _invokeItem.UpdateInvocation();
     return(this);
 }
Exemple #23
0
 public Builder FuncTaskGeneric()
 {
     _funcTaskGeneric.UpdateInvocation();
     return(this);
 }