public void for_conditional_with_the_wrong_kind_of_type()
 {
     Exception <ArgumentOutOfRangeException> .ShouldBeThrownBy(() =>
     {
         ConditionalObjectDef.For(typeof(Model));
     });
 }
        public void for_filter_negative()
        {
            var def = ConditionalObjectDef.For(() => false);

            build(def).ShouldBeOfType <LambdaConditional>().ShouldExecute().ShouldBeFalse();
        }
        public void for_filter_positive()
        {
            var def = ConditionalObjectDef.For(() => true);

            build(def).ShouldBeOfType <LambdaConditional>().ShouldExecute().ShouldBeTrue();
        }
        public void for_conditional_type()
        {
            var def = ConditionalObjectDef.For <AlwaysTrue>();

            build(def).ShouldBeOfType <AlwaysTrue>();
        }
        public void for_conditional_type_positive()
        {
            var def = ConditionalObjectDef.For(typeof(AlwaysTrue));

            def.Type.ShouldEqual(typeof(AlwaysTrue));
        }
Esempio n. 6
0
 /// <summary>
 ///   Make the behavior *only* execute if the condition is met
 /// </summary>
 /// <param name = "condition"></param>
 /// <param name="description"></param>
 public void Condition(Func <bool> condition, string description = "Anonymous")
 {
     Trace(new ConditionAdded(description));
     _conditionalDef = ConditionalObjectDef.For(condition);
 }
Esempio n. 7
0
 /// <summary>
 ///   Makes the behavior execute only if the custom IConditional evaluates
 ///   true
 /// </summary>
 public void Condition <T>() where T : IConditional
 {
     Trace(new ConditionAdded(typeof(T)));
     _conditionalDef = ConditionalObjectDef.For <T>();
 }
Esempio n. 8
0
 public void Condition(Type type)
 {
     Trace(new ConditionAdded(type));
     _conditionalDef = ConditionalObjectDef.For(type);
 }
Esempio n. 9
0
 /// <summary>
 /// Makes the behavior execute only if the custom IConditional evaluates
 /// true
 /// </summary>
 public void Condition <T>() where T : IConditional
 {
     _conditionalDef = ConditionalObjectDef.For <T>();
 }
Esempio n. 10
0
 /// <summary>
 /// Make the behavior *only* execute if the condition is met
 /// </summary>
 /// <param name="condition"></param>
 public void Condition(Func <bool> condition)
 {
     _conditionalDef = ConditionalObjectDef.For(condition);
 }