private void InvokeMethod(int count = 1)
 {
     for (int i = 0; i < count; i++)
     {
         _instance.TestMethod();
     }
 }
        public void Mock_Should_HaveCalledOnly_should_work_as_expected()
        {
            Action verifyAction = () => _mock.Should().HaveCalledOnly(x => x.TestMethod());

            AssertException(verifyAction, "Expected invocation on the mock once, but was 0 times: x => x.TestMethod");

            _instance.TestMethod();
            AssertSuccess(verifyAction);

            _instance.TestMethod();
            _instance.TestFunction("test");

            _test = _instance.TestProperty;

            AssertException(verifyAction, "The following invocations on mock");
        }
Exemple #3
0
        public void Mock_Should_HaveCallCount_should_work_as_expected_for_method()
        {
            Action verifyAction = () => _mock.Should().HaveCallCount(2).To(x => x.TestMethod());

            AssertException(verifyAction, "Expected invocation on the mock exactly 2 times, but was 0 times: x => x.TestMethod");

            _instance.TestMethod();
            AssertException(verifyAction, "Expected invocation on the mock exactly 2 times, but was 1 times: x => x.TestMethod");

            _instance.TestMethod();
            _instance.TestMethod();
            AssertSuccess(verifyAction);
        }