public void ShouldBeNotFulfilled_WithNotFulfilledDefault_AndOneFulfilledCondiiton()
        {
            var conditionsValidator = new ConditionsValidator()
                                      .WithCondition(ConditionRelation.Or, new NotFulfilledTestCondition())
                                      .WithCondition(ConditionRelation.Or, new FulfilledTestCondition())
                                      .WithDefaultState(ConditionState.NotFulfilled);

            conditionsValidator.Validate().ShouldBeEquivalentTo(ConditionState.Fulfilled);
        }
예제 #2
0
        private bool GetTurnOffConditionsAreFulfilled()
        {
            if (_turnOffConditionsValidator.Conditions.Any() && _turnOffConditionsValidator.Validate() == ConditionState.Fulfilled)
            {
                return(false);
            }

            return(true);
        }
예제 #3
0
        private bool GetConditionsAreFulfilled()
        {
            if (_disablingConditionsValidator.Conditions.Any() && _disablingConditionsValidator.Validate() == ConditionState.Fulfilled)
            {
                return(false);
            }

            if (_enablingConditionsValidator.Conditions.Any() && _enablingConditionsValidator.Validate() == ConditionState.NotFulfilled)
            {
                return(false);
            }

            return(true);
        }
예제 #4
0
 public void Trigger()
 {
     if (_conditionsValidator.Validate() == ConditionState.Fulfilled)
     {
         foreach (var action in ActionsIfFulfilled)
         {
             action();
         }
     }
     else
     {
         foreach (var action in ActionsIfNotFulfilled)
         {
             action();
         }
     }
 }
예제 #5
0
 private bool CanTurnOffLamp() => _turnOffConditionsValidator.Validate() != ConditionState.NotFulfilled;