Exemple #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'");
        }
 private void Evaluate()
 {
     if (TargetObject != null)
     {
         VisualStateUtilities.GoToState(stateName: (!ComparisonLogic.EvaluateImpl(Binding, ComparisonConditionType.Equal, Value)) ? FalseState : TrueState, element: TargetObject, useTransitions: true);
     }
 }
Exemple #3
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.");
        }
Exemple #4
0
        public void Compare_DifferentIntegers_AreNotEqual()
        {
            bool result = ComparisonLogic.EvaluateImpl(BehaviorTestUtilities.IntegerOperand4,
                                                       ComparisonConditionType.NotEqual,
                                                       BehaviorTestUtilities.IntegerOperand5);

            Assert.IsTrue(result, "4 should not equal 5.");
        }
Exemple #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.");
        }
Exemple #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.");
        }
Exemple #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.");
        }
Exemple #8
0
        public void Compare_EqualIntegers_AreFoundEqual()
        {
            bool result = ComparisonLogic.EvaluateImpl(BehaviorTestUtilities.IntegerOperand4,
                                                       ComparisonConditionType.Equal,
                                                       BehaviorTestUtilities.IntegerOperand4);

            Assert.IsTrue(result, "4 should equal 4.");
        }
Exemple #9
0
 private bool Compare()
 {
     if (this.AssociatedObject != null)
     {
         return(ComparisonLogic.EvaluateImpl(this.Binding, this.Comparison, this.Value));
     }
     return(false);
 }
Exemple #10
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.");
        }
Exemple #11
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.");
        }
Exemple #12
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.");
        }
Exemple #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.");
        }
        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);
            }
        }
Exemple #15
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'");
        }
 /// <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));
 }
Exemple #17
0
        public void Compare_NullToNull_IsEqual()
        {
            bool result = ComparisonLogic.EvaluateImpl(null, ComparisonConditionType.Equal, null);

            Assert.IsTrue(result, "Null should be equal to null.");
        }
Exemple #18
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.");
        }
Exemple #19
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");
        }
Exemple #20
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");
        }
Exemple #21
0
        public void Compare_ComparableObjectWithNonComparableObjectLessThanOrEqual_ThrowsArgumentException()
        {
            StubClass stubClass = CreateStubClass();

            ComparisonLogic.EvaluateImpl(BehaviorTestUtilities.IntegerOperand4, ComparisonConditionType.LessThanOrEqual, stubClass);
        }
Exemple #22
0
 public void Compare_NullWithComparableObjectLessThanOrEqual_ThrowsArgumentException()
 {
     ComparisonLogic.EvaluateImpl(null, ComparisonConditionType.LessThanOrEqual, BehaviorTestUtilities.IntegerOperand4);
 }
Exemple #23
0
 public void Compare_NullWithNullLessThanOrEqual_ThrowsArgumentException()
 {
     ComparisonLogic.EvaluateImpl(null, ComparisonConditionType.LessThanOrEqual, null);
 }