예제 #1
0
        public void Compare_BrushWithBrushString_AreEqual()
        {
            System.Windows.Media.SolidColorBrush brush = System.Windows.Media.Brushes.Red;
            bool result = ComparisonLogic.EvaluateImpl(brush, ComparisonConditionType.Equal, "Red");

            Assert.IsTrue(result, "Red brush should equal 'Red'");
        }
예제 #2
0
 private void Evaluate()
 {
     if (TargetObject != null)
     {
         VisualStateUtilities.GoToState(stateName: (!ComparisonLogic.EvaluateImpl(Binding, ComparisonConditionType.Equal, Value)) ? FalseState : TrueState, element: TargetObject, useTransitions: true);
     }
 }
예제 #3
0
        public void Compare_DifferentIntegers_AreNotEqual()
        {
            bool result = ComparisonLogic.EvaluateImpl(BehaviorTestUtilities.IntegerOperand4,
                                                       ComparisonConditionType.NotEqual,
                                                       BehaviorTestUtilities.IntegerOperand5);

            Assert.IsTrue(result, "4 should not equal 5.");
        }
예제 #4
0
        public void Compare_DifferentIntegers_FourLessThanFive()
        {
            bool result = ComparisonLogic.EvaluateImpl(BehaviorTestUtilities.IntegerOperand4,
                                                       ComparisonConditionType.LessThan,
                                                       BehaviorTestUtilities.IntegerOperand5);

            Assert.IsTrue(result, "4 should be less than 5.");
        }
예제 #5
0
        public void Compare_DifferentIntegers_FourNotGreaterThanFive()
        {
            bool result = ComparisonLogic.EvaluateImpl(BehaviorTestUtilities.IntegerOperand4,
                                                       ComparisonConditionType.GreaterThan,
                                                       BehaviorTestUtilities.IntegerOperand5);

            Assert.IsFalse(result, "4 should not be greater than 5.");
        }
예제 #6
0
        public void Compare_SameString_AreEqual()
        {
            bool result = ComparisonLogic.EvaluateImpl(BehaviorTestUtilities.StringOperandLoremIpsum,
                                                       ComparisonConditionType.Equal,
                                                       BehaviorTestUtilities.StringOperandLoremIpsum);

            Assert.IsTrue(result, "Identical strings should be found equal.");
        }
예제 #7
0
        public void Compare_DifferentStrings_AreNotEqual()
        {
            bool result = ComparisonLogic.EvaluateImpl(BehaviorTestUtilities.StringOperandLoremIpsum,
                                                       ComparisonConditionType.Equal,
                                                       BehaviorTestUtilities.StringOperandNuncViverra);

            Assert.IsFalse(result, "Different strings should not be found equal.");
        }
예제 #8
0
 private bool Compare()
 {
     if (this.AssociatedObject != null)
     {
         return(ComparisonLogic.EvaluateImpl(this.Binding, this.Comparison, this.Value));
     }
     return(false);
 }
예제 #9
0
        public void Compare_EqualIntegers_AreFoundEqual()
        {
            bool result = ComparisonLogic.EvaluateImpl(BehaviorTestUtilities.IntegerOperand4,
                                                       ComparisonConditionType.Equal,
                                                       BehaviorTestUtilities.IntegerOperand4);

            Assert.IsTrue(result, "4 should equal 4.");
        }
예제 #10
0
        public void Compare_SameObject_AreEqual()
        {
            StubClass stubClass = CreateStubClass();
            bool      result    = ComparisonLogic.EvaluateImpl(stubClass,
                                                               ComparisonConditionType.Equal,
                                                               stubClass);

            Assert.IsTrue(result, "An object should be equal to itself.");
        }
예제 #11
0
        public void Compare_IntegerToEquivalentIComparableObject_IsEqual()
        {
            StubComparableConvertibleClass stubComparableConvertibleClass = new StubComparableConvertibleClass();
            bool result = ComparisonLogic.EvaluateImpl(BehaviorTestUtilities.IntegerOperand4,
                                                       ComparisonConditionType.Equal,
                                                       stubComparableConvertibleClass);

            Assert.IsTrue(result, "An integer should be equal to an IComparableObject that reports the same value as the integer.");
        }
예제 #12
0
        public void Compare_IntegerToObject_IsNotEqual()
        {
            StubClass stubClass = CreateStubClass();
            bool      result    = ComparisonLogic.EvaluateImpl(BehaviorTestUtilities.IntegerOperand4,
                                                               ComparisonConditionType.Equal,
                                                               stubClass);

            Assert.IsFalse(result, "An integer should not be equal to an arbitrary object.");
        }
예제 #13
0
        public void Compare_ObjectToIComparable_AreNotEqual()
        {
            StubClass           stubClass           = CreateStubClass();
            StubComparableClass stubComparableClass = CreateStubComparableClass();
            bool result = ComparisonLogic.EvaluateImpl(stubClass,
                                                       ComparisonConditionType.NotEqual,
                                                       stubComparableClass);

            Assert.IsTrue(result, "An arbitrary object should not be equal to another arbitrary object.");
        }
        /// <summary>
        /// This method is called each time our source binding changes
        /// </summary>
        /// <param name="e"></param>
        private void EvaluateBindingChange(DependencyPropertyChangedEventArgs e)
        {
            DataBindingHelper.EnsureDataBindingOnActionsUpToDate(this.Actions);

            bool hasValue = (base.ReadLocalValue(ValueProperty) != DependencyProperty.UnsetValue);

            if (!hasValue || ComparisonLogic.Evaluate(Binding, ComparisonCondition, Value))
            {
                // Pass the result of the binding
                Interaction.ExecuteActions(AssociatedObject, Actions, Binding);
            }
        }
예제 #15
0
        private void Evaluate()
        {
            if (this.TargetObject != null)
            {
                string stateName = null;
                if (ComparisonLogic.EvaluateImpl(this.Binding, ComparisonConditionType.Equal, this.Value))
                {
                    stateName = this.TrueState;
                }
                else
                {
                    stateName = this.FalseState;
                }

                VisualStateUtilities.GoToState(this.TargetObject, stateName, true);
            }
        }
예제 #16
0
        public void Compare_DoubleWithInconvertibleString_IsNotEqual()
        {
            bool result = ComparisonLogic.EvaluateImpl(ComparisonLogicTest.DoubleOperand, ComparisonConditionType.NotEqual, ComparisonLogicTest.NonIntegerString);

            Assert.IsTrue(result, "Double should not be equal to 'Foo'");
        }
예제 #17
0
        public void Compare_NullToNull_IsEqual()
        {
            bool result = ComparisonLogic.EvaluateImpl(null, ComparisonConditionType.Equal, null);

            Assert.IsTrue(result, "Null should be equal to null.");
        }
예제 #18
0
 /// <summary>
 /// Method which performs the comparison
 /// </summary>
 /// <returns>True/False for equality</returns>
 private bool Compare()
 {
     return((base.AssociatedObject != null) &&
            ComparisonLogic.Evaluate(base.Binding, this.Comparison, this.Value));
 }
예제 #19
0
        public void Compare_NullToInteger_IsNotEqual()
        {
            bool result = ComparisonLogic.EvaluateImpl(null, ComparisonConditionType.Equal, BehaviorTestUtilities.IntegerOperand4);

            Assert.IsFalse(result, "Null should not be equal to an integer.");
        }
예제 #20
0
 /// <summary>
 /// Method that evaluates the condition. Note that this method can throw ArgumentException if the operator is
 /// incompatible with the type. For instance, operators LessThan, LessThanOrEqual, GreaterThan, and GreaterThanOrEqual
 /// require both operators to implement IComparable.
 /// </summary>
 /// <returns>Returns true if the condition has been met; otherwise, returns false.</returns>
 public bool Evaluate()
 {
     this.EnsureBindingUpToDate();
     return(ComparisonLogic.EvaluateImpl(this.LeftOperand, this.Operator, this.RightOperand));
 }
예제 #21
0
        public void Compare_IntegerWithNullNotEqual_IsTrue()
        {
            bool result = ComparisonLogic.EvaluateImpl(BehaviorTestUtilities.IntegerOperand4, ComparisonConditionType.NotEqual, null);

            Assert.IsTrue(result, "4 is not equal to null, so NotEquals should return true");
        }
예제 #22
0
        public void Compare_NullWithNullNotEqual_IsFalse()
        {
            bool result = ComparisonLogic.EvaluateImpl(null, ComparisonConditionType.NotEqual, null);

            Assert.IsFalse(result, "null is equal to null, so NotEquals should return false");
        }
예제 #23
0
        public void Compare_ComparableObjectWithNonComparableObjectLessThanOrEqual_ThrowsArgumentException()
        {
            StubClass stubClass = CreateStubClass();

            ComparisonLogic.EvaluateImpl(BehaviorTestUtilities.IntegerOperand4, ComparisonConditionType.LessThanOrEqual, stubClass);
        }
예제 #24
0
 public void Compare_NullWithComparableObjectLessThanOrEqual_ThrowsArgumentException()
 {
     ComparisonLogic.EvaluateImpl(null, ComparisonConditionType.LessThanOrEqual, BehaviorTestUtilities.IntegerOperand4);
 }
예제 #25
0
 public void Compare_NullWithNullLessThanOrEqual_ThrowsArgumentException()
 {
     ComparisonLogic.EvaluateImpl(null, ComparisonConditionType.LessThanOrEqual, null);
 }