public void AddRuleForTypeMustFailRegExCollect4() { var messages = Bouncer.ForMessages("hello", "theValue").Assert(new ConfigurationValidatorBaseRule <string>(new System.Configuration.StringValidator(8))).Results; var actual = messages.First().Message; Assert.AreEqual(messages.First().ToString(), actual); }
public void ContractContextInsert(AttributedSampleClass sample) { var result = Bouncer.ForMessages(() => sample).Assert().Results; this.Content = result.ToList().Count.ToString(); this.CountOfEvents++; }
public void AddRuleForTypeMustFailRegExCollect3() { var messages = Bouncer.ForMessages("hello", "theValue").Assert(new ConfigurationValidatorBaseRule <string>(new System.Configuration.StringValidator(8))).Results; var actual = messages.First().Message; Assert.AreEqual("The rule Sem.GenericHelpers.Contracts.Rules.ConfigurationValidatorBaseRule`1 did fail for value name >>theValue<<: The validator System.Configuration.StringValidator did throw an exception.", actual); }
public void Handle3(MessageOne message) { var result = Bouncer.ForMessages(() => message).Assert().Results; this.Content = result.ToList().Count.ToString(); this.CountOfEvents++; }
public void AddRuleForTypeMustSucceedRegExCollect4() { var configurationValidatorBaseRule = new ConfigurationValidatorBaseRule <string>(new System.Configuration.StringValidator(8)); var messages = Bouncer.ForMessages("hello I have more than 8 chars", "theValue").Assert(configurationValidatorBaseRule).Results; var actual = messages.ToList().Count; Assert.AreEqual(0, actual); }
public void CheckRuleSet2() { var messages = Bouncer .ForMessages(() => MessageOneFailRegEx) .ForMessages(() => MessageOneFailRegEx2) .Assert(); Assert.AreEqual(6, messages.Results.ToList().Count); }
public IEnumerable <RuleValidationResult> CheckCustomerWithWithMethodAttributes(string customerId, int amount, MyCustomer theCustomer) { var results = Bouncer .ForMessages(() => customerId) .ForMessages(() => amount) .ForMessages(() => theCustomer) .Assert().Results; return(results); }
/// <summary> /// This time we will not prevent executing the method code, but /// just collect the violated rules and print them to the console. /// The rule is a custom one that checks for a specific string inside /// a specific property. You might reuse such logic by inheriting /// from RuleBase and initialize the CheckExpression inside the /// constructor. /// </summary> /// <param name="customer"></param> internal IEnumerable <RuleValidationResult> CheckCustomerWithCustomRule(MyCustomer customer) { var results = Bouncer .ForMessages(() => customer) .Assert(new RuleBase <MyCustomer, object> { Message = "Sven cannot enter this method", CheckExpression = (x, y) => x.FullName != "Sven" }).Results; return(results); }
/// <summary> /// This time we will not prevent executing the method code, but /// just collect the violated rules and print them to the console. /// The rule is a custom one that checks for a specific string inside /// a specific property. You might reuse such logic by inheriting /// from RuleBase and initialize the CheckExpression inside the /// constructor. /// </summary> /// <param name="customer"></param> internal void CheckCustomerWithCustomRule(MyCustomer customer) { var results = Bouncer .ForMessages(() => customer) .Assert(new RuleBase <MyCustomer, object> { Message = "Sven cannot enter this method", CheckExpression = (x, y) => x.FullName != "Sven" }); Util.PrintEntries(results); Console.WriteLine("---> ForMessages did return the validation results, but <---"); Console.WriteLine("---> did not cause any exception. So \"customer Sven\" <---"); Console.WriteLine("---> did enter the method and did execute all code. <---"); }
public void CheckCustomerWithWithMethodAttributes(string customerId, int amount, MyCustomer theCustomer) { Bouncer .ForCheckData(() => customerId) .ForCheckData(() => amount) .ForCheckData(() => theCustomer) .Assert(); var results = Bouncer .ForMessages(() => customerId) .ForMessages(() => amount) .ForMessages(() => theCustomer) .Assert(); Util.PrintEntries(results); }
/// <summary> /// This time we will not prevent executing the method code, but /// just collect the violated rules and print them to the console. /// </summary> /// <param name="customer"></param> internal void CheckCustomerProperties(MyCustomer customer) { var results = Bouncer.ForMessages(() => customer).Assert(); Util.PrintEntries(results); }
internal void InsertCustomer(MyCustomer customer) { var results = Bouncer.ForMessages(() => customer).Assert(); Util.PrintEntries(results); }
public void AddRuleForTypeMustFailRegExCollect2() { var message = Bouncer.ForMessages(MessageOneFailRegEx, "_MessageOneFailRegEx").Assert().Results; Assert.IsTrue(message.First().Message.Contains("_MessageOneFailRegEx.MustBeOfRegExPatter must be of reg ex '.ell.!'")); }
internal IEnumerable <RuleValidationResult> InsertCustomer(MyCustomer customer) { var results = Bouncer.ForMessages(() => customer).Assert().Results; return(results); }
/// <summary> /// This time we will not prevent executing the method code, but /// just collect the violated rules and print them to the console. /// </summary> /// <param name="customer"></param> internal IEnumerable <RuleValidationResult> CheckCustomerProperties(MyCustomer customer) { return(Bouncer.ForMessages(() => customer).Assert().Results); }