public List<IPrimitiveConditionData> GenerateRules(List<TouchPoint2> points)
        {
            List<IPrimitiveConditionData> data = new List<IPrimitiveConditionData>();
            //Validate(points);
            bool singlePoint;
            double length = 0;
            foreach (var point in points)
            {
                if (!point.isFinger)
                {
                    data.Add(null);
                    continue;
                }

                singlePoint = TrigonometricCalculationHelper.isASinglePoint(point);
                if (singlePoint)
                    continue;
                length = TrigonometricCalculationHelper.CalculatePathLength(point);
                TouchPathLength _return = new TouchPathLength();
                _return.Max = length;
                _return.Min = 0;
                data.Add(_return);
            }

            return data;
        }
Example #2
0
        public void TouchPathLength_Max_Setter_Not_Set_Test()
        {
            // The type we are testing
            TouchPathLength target = new TouchPathLength();

            //Since the max was not set, we are verifying that it was set to 0 as specified in original code
            bool expected = true;
            bool actual = target.Max.Equals(0);

            //Assert they are equal
            Assert.AreEqual(expected, actual);
        }
Example #3
0
        public void TouchPathLength_Max_Setter_Test()
        {
            // The type we are testing
            TouchPathLength target = new TouchPathLength()
            {
                Max = 3
            };

            //The max was set to 3, so we confirm that the min was indeed set to 3
            bool expected = true;
            bool actual = target.Max.Equals(3);

            //Assert they are equal
            Assert.AreEqual(expected, actual);
        }
Example #4
0
        public void TouchPathLength_Max_Getter_Test()
        {
            // The type we are testing
            TouchPathLength target = new TouchPathLength()
            {
                Max = 5
            };

            //The max was set to 5, so test the getter to check if it returns 5
            bool expected = true;
            int actualMax = 5;
            bool actual = actualMax == target.Max;
            //Assert they are equal
            Assert.AreEqual(expected, actual);
        }
        public IPrimitiveConditionData GenerateRuleData(List<TouchPoint2> points)
        {
            //Validate(points);
            bool singlePoint;
            double length = 0;
            foreach (var point in points)
            {
                singlePoint = TrigonometricCalculationHelper.isASinglePoint(point);
                if (singlePoint)
                    return null;
                length = TrigonometricCalculationHelper.CalculatePathLength(point);
            }

            TouchPathLength _return = new TouchPathLength();
            _return.Max = length;
            _return.Min = 0;
            return _return;
        }
 public void Init(IPrimitiveConditionData ruleData)
 {
     _data = ruleData as TouchPathLength;
 }
Example #7
0
        public void TouchPathLength_Min_Getter_Test()
        {
            // The type we are testing
            TouchPathLength target = new TouchPathLength()
            {
                Min = -1
            };

            //The min was set to -1, so test the getter to check if it returns -1
            bool expected = true;
            int actualMin = -1;
            bool actual = actualMin == target.Min;

            //Assert they are equal
            Assert.AreEqual(expected, actual);
        }
Example #8
0
        public void TouchPathLength_Union_With_A_Null_Test()
        {
            // The type we are testing
            TouchPathLength target = new TouchPathLength();

            // Since the ruleData is null, the union should fail
            IPrimitiveConditionData anotherRuleData = null;

            //Union should fail
            target.Union(anotherRuleData);
        }
Example #9
0
        public void TouchPathLength_Union_Nothing_Set_Test()
        {
            // The type we are testing
            TouchPathLength target = new TouchPathLength()
            {
                Max = 7,
                Min = 1
            };

            // Another instance of same type of ruleData
            IPrimitiveConditionData anotherRuleData = new TouchPathLength()
            {
                Max = 5,
                Min = 3
            };

            //Union the 2 rules
            target.Union(anotherRuleData);

            //We expect the value of the min to remain the same as the original rule, which is 1
            bool expected = true;
            bool actual = target.Min.Equals(1);

            //Assert they are equal
            Assert.AreEqual(expected, actual);

            //We expect the value of the min to remain the same as the original rule, which is 7
            actual = target.Max.Equals(7);

            //Assert they are equal
            Assert.AreEqual(expected, actual);
        }
Example #10
0
        public void TouchPathLength_Union_Min_Test()
        {
            // The type we are testing
            TouchPathLength target = new TouchPathLength()
            {
                Max = 5,
                Min = 3
            };

            // Another instance of same type of ruleData
            IPrimitiveConditionData anotherRuleData = new TouchPathLength()
            {
                Max = 5,
                Min = 1
            };

            //Union the 2 rules
            target.Union(anotherRuleData);

            //We expect the value of the min when union'd, to be the min of the 2nd rule, which is 1
            bool expected = true;
            bool actual = target.Min.Equals(1);

            //Assert they are equal
            Assert.AreEqual(expected, actual);
        }
Example #11
0
        public void TouchPathLength_Union_Both_Max_And_Min_Test()
        {
            // The type we are testing
            TouchPathLength target = new TouchPathLength()
            {
                Max = 3,
                Min = 2
            };

            // Another instance of same type of ruleData
            IPrimitiveConditionData anotherRuleData = new TouchPathLength()
            {
                Max = 5,
                Min = 0
            };

            //Union the 2 rules
            target.Union(anotherRuleData);

            //We expect the value of the min to become the value of the 2nd rule, which is 0
            bool expected = true;
            bool actual = target.Min.Equals(0);

            //Assert they are equal
            Assert.AreEqual(expected, actual);

            //We expect the value of the max to become the value of the 2nd rule, which is 5
            actual = target.Max.Equals(5);

            //Assert they are equal
            Assert.AreEqual(expected, actual);
        }
Example #12
0
        public void TouchPathLength_toGDL_Test_With_Nothing_Set()
        {
            // The type we are testing
            TouchPathLength target = new TouchPathLength();

            // Since the nothing was set in constructor, resulting value for max and min should be 0f
            bool expected = true;
            bool actual = target.ToGDL().Equals("Touch path length: 0..0");

            //Assert they are equal
            Assert.AreEqual(expected, actual);
        }
Example #13
0
        public void TouchPathLength_toGDL_Test_With_Min_Set()
        {
            // The type we are testing
            TouchPathLength target = new TouchPathLength()
            {
                Min = 1
            };

            // Since the min was set in the constructor, this should be reflected in the output string
            bool expected = true;
            bool actual = target.ToGDL().Equals("Touch path length: 1..0");

            //Assert they are equal
            Assert.AreEqual(expected, actual);
        }