Пример #1
0
        public static void CallCountConstraintWithMatchingNumberOfCalls(CountableCall call, CallCountAsserter callCountAsserter, IFoo fake, Exception exception)
        {
            "Given a Fake"
            .x(() => fake = A.Fake <IFoo>());

            $"And I make {callCountAsserter.NumberOfCalls} calls to the fake"
            .x(() =>
            {
                for (int i = 0; i < callCountAsserter.NumberOfCalls; ++i)
                {
                    call.Invoke(fake);
                }
            });

            $"When I assert {callCountAsserter.AssertionDescription}"
            .x(() => exception = Record.Exception(() => callCountAsserter.AssertCallCount(call.BeginAssertion(fake))));

            "Then the assertion passes"
            .x(() => exception.Should().BeNull());
        }
Пример #2
0
        public static void CallCountConstraintWithNonMatchingNumberOfCalls(CountableCall call, CallCountAsserter callCountAsserter, IFoo fake, Exception exception)
        {
            "Given a Fake"
            .x(() => fake = A.Fake <IFoo>());

            $"And I make {callCountAsserter.NumberOfCalls} calls to the fake"
            .x(() =>
            {
                for (int i = 0; i < callCountAsserter.NumberOfCalls; ++i)
                {
                    call.Invoke(fake);
                }
            });

            $"When I assert {callCountAsserter.AssertionDescription}"
            .x(() => exception = Record.Exception(() => callCountAsserter.AssertCallCount(call.BeginAssertion(fake))));

            "Then the assertion fails"
            .x(() => exception.Should().BeAnExceptionOfType <ExpectationException>()
               .WithMessageModuloLineEndings($"*\r\nExpected to find it {callCountAsserter.AssertionError}*"));
        }