Пример #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);
 }