Ejemplo n.º 1
0
        public void CanRunActionValidation()
        {
            var action = new TestAction("matt", DateTime.Now);

            action.Execute();
            Assert.IsFalse(action.ValidationContext.IsValid);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="TestRule" /> class.
 /// </summary>
 /// <param name="name"> The name. </param>
 /// <param name="message"> The message. </param>
 public TestRule(string name, string message, TestAction target) : base(name, message)
 {
     RenderType = RenderType.EvaluateAllRules;
     Rules.Add(new IsNotNullRule("TestActionIsNotNull", "The action cannot be null.", target));
     if (target != null)
     {
         Rules.Add(new StringIsNotEmptySpace("NameIsValid", "The name cannot be empty string.", target.Name));
         Rules.Add(new Range <DateTime>("CurrentDateIsValid", "The date must be within date range.", target.CurrentDateTime, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(1)));
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="TestRule" /> class.
 /// </summary>
 /// <param name="name"> The name. </param>
 /// <param name="message"> The message. </param>
 public TestRule(string name, string message, TestAction target)
     : base(name, message)
 {
     RenderType = RenderType.EvaluateAllRules;
     Rules.Add(new IsNotNullRule("TestActionIsNotNull", "The action cannot be null.", target));
     if (target != null)
     {
         Rules.Add(new StringIsNotEmptySpace("NameIsValid", "The name cannot be empty string.", target.Name));
         Rules.Add(new Range<DateTime>("CurrentDateIsValid", "The date must be within date range.", target.CurrentDateTime, DateTime.Now.AddDays(-1), DateTime.Now.AddDays(1)));
     }
 }
Ejemplo n.º 4
0
 public void CanRunActionValidation()
 {
     var action = new TestAction("matt", DateTime.Now);
     action.Execute();
     Assert.IsFalse(action.ValidationContext.IsValid);
 }