コード例 #1
0
        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);
        }
コード例 #2
0
        public void ContractContextInsert(AttributedSampleClass sample)
        {
            var result = Bouncer.ForMessages(() => sample).Assert().Results;

            this.Content = result.ToList().Count.ToString();
            this.CountOfEvents++;
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        public void Handle3(MessageOne message)
        {
            var result = Bouncer.ForMessages(() => message).Assert().Results;

            this.Content = result.ToList().Count.ToString();
            this.CountOfEvents++;
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        public void CheckRuleSet2()
        {
            var messages = Bouncer
                           .ForMessages(() => MessageOneFailRegEx)
                           .ForMessages(() => MessageOneFailRegEx2)
                           .Assert();

            Assert.AreEqual(6, messages.Results.ToList().Count);
        }
コード例 #7
0
        public IEnumerable <RuleValidationResult> CheckCustomerWithWithMethodAttributes(string customerId, int amount, MyCustomer theCustomer)
        {
            var results = Bouncer
                          .ForMessages(() => customerId)
                          .ForMessages(() => amount)
                          .ForMessages(() => theCustomer)
                          .Assert().Results;

            return(results);
        }
コード例 #8
0
        /// <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);
        }
コード例 #9
0
        /// <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.   <---");
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        /// <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);
        }
コード例 #12
0
        internal void InsertCustomer(MyCustomer customer)
        {
            var results = Bouncer.ForMessages(() => customer).Assert();

            Util.PrintEntries(results);
        }
コード例 #13
0
        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.!'"));
        }
コード例 #14
0
        internal IEnumerable <RuleValidationResult> InsertCustomer(MyCustomer customer)
        {
            var results = Bouncer.ForMessages(() => customer).Assert().Results;

            return(results);
        }
コード例 #15
0
 /// <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);
 }