public void Where_should_return_the_configuration_object() { // Arrange var returnConfig = new RuleBuilder.ReturnValueConfiguration <int>(this.builder); // Act // Assert returnConfig.Where(x => true, x => { }).Should().BeSameAs(returnConfig); }
public void WhenArgumentsMatches_with_function_call_should_call_UsePredicateToValidateArguments_on_built_rule() { var builtRule = A.Fake <BuildableCallRule>(); var config = this.CreateBuilder(builtRule); var returnConfig = new RuleBuilder.ReturnValueConfiguration <bool>(config); Func <ArgumentCollection, bool> predicate = x => true; returnConfig.WhenArgumentsMatch(predicate); A.CallTo(() => builtRule.UsePredicateToValidateArguments(predicate)).MustHaveHappened(); }
public void Where_should_return_the_configuration_object() { // Arrange var returnConfig = new RuleBuilder.ReturnValueConfiguration <int>() { ParentConfiguration = this.builder }; // Act // Assert Assert.That(returnConfig.Where(x => true, x => { }), Is.SameAs(returnConfig)); }
public void Where_should_apply_where_predicate_to_built_rule() { // Arrange Func <IFakeObjectCall, bool> predicate = x => true; Action <IOutputWriter> writer = x => { }; var returnConfig = new RuleBuilder.ReturnValueConfiguration <int>(this.builder); // Act returnConfig.Where(predicate, writer); // Assert A.CallTo(() => this.ruleProducedByFactory.ApplyWherePredicate(predicate, writer)).MustHaveHappened(); }
public void Assert_with_function_call_should_remove_built_rule_from_fake_object() { // Arrange this.fakeManager.AddRuleFirst(this.ruleProducedByFactory); // Act var returnConfig = new RuleBuilder.ReturnValueConfiguration <int> { ParentConfiguration = this.builder }; returnConfig.MustHaveHappened(); // Assert this.fakeManager.Rules.Should().BeEmpty(); }
public void Assert_with_function_call_should_remove_built_rule_from_fake_object() { // Arrange this.fakeObject.AddRule(this.ruleProducedByFactory); // Act var returnConfig = new RuleBuilder.ReturnValueConfiguration <int>() { ParentConfiguration = this.builder }; returnConfig.Assert(Happened.Once); // Assert Assert.That(this.fakeObject.Rules, Is.Empty); }
public void Assert_with_function_call_should_assert_on_assertions_produced_by_factory() { // Arrange A.CallTo(() => this.ruleProducedByFactory.DescriptionOfValidCall).Returns("call description"); // Act var returnConfig = new RuleBuilder.ReturnValueConfiguration <int>() { ParentConfiguration = this.builder }; returnConfig.MustHaveHappened(Repeated.Exactly.Times(99)); // Assert A.CallTo(() => this.asserter.AssertWasCalled(A <Func <IFakeObjectCall, bool> > ._, "call description", A <Func <int, bool> > .That.Matches(x => x.Invoke(99)), "exactly 99 times")).MustHaveHappened(); }
public void Assert_with_function_call_should_assert_on_assertions_produced_by_factory() { // Arrange var repeatedConstraint = Repeated.Exactly.Times(99); // Act var returnConfig = new RuleBuilder.ReturnValueConfiguration <int>(this.builder); returnConfig.MustHaveHappened(repeatedConstraint); // Assert A.CallTo(() => this.asserter.AssertWasCalled( A <Func <ICompletedFakeObjectCall, bool> > ._, this.ruleProducedByFactory.WriteDescriptionOfValidCall, repeatedConstraint)) .MustHaveHappened(); }
public void WhenArgumentsMatches_with_function_call_should_call_UsePredicateToValidateArguments_on_built_rule() { var builtRule = A.Fake <BuildableCallRule>(); var config = this.CreateBuilder(builtRule); var returnConfig = new RuleBuilder.ReturnValueConfiguration <bool>() { ParentConfiguration = config }; Func <ArgumentCollection, bool> predicate = x => true; returnConfig.WhenArgumentsMatch(predicate); Fake.Assert(builtRule) .WasCalled(x => x.UsePredicateToValidateArguments(predicate)); }
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.Assert(Happened.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")).Assert(Happened.Once); }
public void MustHaveHappened_with_function_call_should_assert_on_assertions_produced_by_factory() { // Arrange Expression <Func <int, bool> > repeatPredicate = x => x == 99; A.CallTo(() => this.ruleProducedByFactory.ToString()).Returns("call description"); // Act var returnConfig = new RuleBuilder.ReturnValueConfiguration <int>() { ParentConfiguration = this.builder }; returnConfig.MustHaveHappened(repeatPredicate); // 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, "the number of times specified by the predicate 'x => (x = 99)'")).MustHaveHappened(); }
public void Where_should_return_the_configuration_object() { // Arrange var returnConfig = new RuleBuilder.ReturnValueConfiguration<int> { ParentConfiguration = this.builder }; // Act // Assert returnConfig.Where(x => true, x => { }).Should().BeSameAs(returnConfig); }
public void Where_should_apply_where_predicate_to_built_rule() { // Arrange Func<IFakeObjectCall, bool> predicate = x => true; Action<IOutputWriter> writer = x => { }; var returnConfig = new RuleBuilder.ReturnValueConfiguration<int> { ParentConfiguration = this.builder }; // Act returnConfig.Where(predicate, writer); // Assert A.CallTo(() => this.ruleProducedByFactory.ApplyWherePredicate(predicate, writer)).MustHaveHappened(); }
public void Assert_with_function_call_should_remove_built_rule_from_fake_object() { // Arrange this.fakeManager.AddRuleFirst(this.ruleProducedByFactory); // Act var returnConfig = new RuleBuilder.ReturnValueConfiguration<int> { ParentConfiguration = this.builder }; returnConfig.MustHaveHappened(); // Assert this.fakeManager.Rules.Should().BeEmpty(); }
public void Assert_with_function_call_should_assert_on_assertions_produced_by_factory() { // Arrange A.CallTo(() => this.ruleProducedByFactory.DescriptionOfValidCall).Returns("call description"); // Act var returnConfig = new RuleBuilder.ReturnValueConfiguration<int> { ParentConfiguration = this.builder }; returnConfig.MustHaveHappened(Repeated.Exactly.Times(99)); // Assert A.CallTo(() => this.asserter.AssertWasCalled( A<Func<IFakeObjectCall, bool>>._, "call description", A<Func<int, bool>>.That.Matches(x => x.Invoke(99)), "exactly 99 times")) .MustHaveHappened(); }
public void WhenArgumentsMatches_with_function_call_should_call_UsePredicateToValidateArguments_on_built_rule() { var builtRule = A.Fake<BuildableCallRule>(); var config = this.CreateBuilder(builtRule); var returnConfig = new RuleBuilder.ReturnValueConfiguration<bool> { ParentConfiguration = config }; Func<ArgumentCollection, bool> predicate = x => true; returnConfig.WhenArgumentsMatch(predicate); A.CallTo(() => builtRule.UsePredicateToValidateArguments(predicate)).MustHaveHappened(); }