public bool Never_should_return_instance_that_matches_one_or_above(int expectedRepeat, int repeat)
        {
            // Arrange
            var times = Repeated.Times(expectedRepeat);

            // Act

            // Assert
            return(times.Matches(repeat));
        }
Exemplo n.º 2
0
        public void Assert_happened_times_should_pass_when_call_has_happened_specified_number_of_times()
        {
            // Arrange
            this.foo.Bar();
            this.foo.Bar();
            this.foo.Bar();

            // Act

            // Assert
            A.CallTo(() => foo.Bar()).MustHaveHappened(Repeated.Times(3));
        }
        public void Assert_with_void_call_should_assert_on_assertions_produced_by_factory()
        {
            // Arrange
            A.CallTo(() => this.ruleProducedByFactory.ToString()).Returns("call description");

            // Act
            this.builder.MustHaveHappened(Repeated.Times(99).Exactly);

            // Assert
            var repeatMatcher = A <Func <int, bool> > .That.Matches(x => x.Invoke(99) == true);

            Fake.Assert(this.asserter)
            .WasCalled(x => x.AssertWasCalled(A <Func <IFakeObjectCall, bool> > .Ignored, "call description", repeatMatcher, "exactly #99 times"));
        }
        public void Assert_with_function_call_should_assert_on_assertions_produced_by_factory()
        {
            // Arrange
            A.CallTo(() => this.ruleProducedByFactory.ToString()).Returns("call description");

            // Act
            var returnConfig = new RuleBuilder.ReturnValueConfiguration <int>()
            {
                ParentConfiguration = this.builder
            };

            returnConfig.MustHaveHappened(Repeated.Times(99).Exactly);

            // Assert
            var repeatMatcher = A <Func <int, bool> > .That.Matches(x => x.Invoke(99) == true);

            A.CallTo(() => this.asserter.AssertWasCalled(A <Func <IFakeObjectCall, bool> > .Ignored, "call description", repeatMatcher, "exactly #99 times")).MustHaveHappened(Repeated.Once);
        }
Exemplo n.º 5
0
        public void Asserting_on_calls()
        {
            var factory = A.Fake <IWidgetFactory>();

            // This would throw an exception since no call has been made.
            A.CallTo(() => factory.Create()).MustHaveHappened(Repeated.Once);
            A.CallTo(() => factory.Create()).MustHaveHappened(Repeated.Twice);
            A.CallTo(() => factory.Create()).MustHaveHappened(Repeated.Times(10));

            // This on the other hand would not throw.
            A.CallTo(() => factory.Create()).MustHaveHappened(Repeated.Never);

            // The number of times the call has been made can be restricted so that it must have happened
            // exactly the number of times specified
            A.CallTo(() => factory.Create()).MustHaveHappened(Repeated.Once.Exactly);
            A.CallTo(() => factory.Create()).MustHaveHappened(Repeated.Times(4).Exactly);

            // Then number of times can be specified so that it must not have happened more
            // than the specified number of times.
            A.CallTo(() => factory.Create()).MustHaveHappened(Repeated.Twice.OrLess);
            A.CallTo(() => factory.Create()).MustHaveHappened(Repeated.Times(5).OrLess);
        }