public void When() { Expression <Func <Customer, bool> > expression = x => x.Age.HasValue; IEntityValidationRuleBuilder <Customer, string> ruleBuilder = Substitute.For <IEntityValidationRuleBuilder <Customer, string> >(); ruleBuilder.WhenForAnyArgs(x => x.SetSpecification(null)).Do(x => Assert.AreEqual(expression, x.Arg <ISpecification <Customer> >().Predicate)); EntityPropertyValidationRuleExtensions.When(ruleBuilder, expression); ruleBuilder.ReceivedWithAnyArgs(1).SetSpecification(null); }
public void WhenMustThrowArgumentNullExceptionWhenPredicateIsNull() { Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.When(Substitute.For <IEntityValidationRuleBuilder <Customer, string> >(), null)); }
public void WhenMustThrowArgumentNullExceptionWhenRuleBuilderIsNull() { Assert.Throws <ArgumentNullException>(() => EntityPropertyValidationRuleExtensions.When <Customer, string>(null, x => x.Age != null)); }