Example #1
0
        public void TestTranslatePoint()
        {
            var visualController = new VisualControllerForTest(new CodedImage {
                Size = new Size(4, 3)
            });

            Assert.AreEqual(new Point(4, 6), visualController.TranslateExposedForTest(new Point(3, 4)), "Do simple shift (+1, +2) for test purposes.");

            visualController.OnTouched(new Point(5, 5));
            Assert.AreEqual(new Point(6, 7), visualController.LastProcessedPoint);

            visualController.OnUntouched(new Point(2, 1));
            Assert.AreEqual(new Point(3, 3), visualController.LastProcessedPoint);

            visualController.OnShift(new Point(3, 5));
            Assert.AreEqual(new Point(3, 3), visualController.LastProcessedPoint, "Previous point should have been passed to OnShiftCore method.");
            Assert.AreEqual(new Size(1, 4), visualController.LastProcessedShift, "Shift value should not be translated.");
        }
Example #2
0
        public void TestIsTouching()
        {
            var visualController = new VisualControllerForTest(new CodedImage {
                Size = new Size(4, 3)
            });

            Assert.IsFalse(visualController.IsTouchingExposedForTest, "Should be false by default.");

            visualController.OnTouched(new Point(5, 5));
            Assert.IsTrue(visualController.IsTouchingExposedForTest, "Should be set to true.");

            visualController.OnTouched(new Point(3, 3));
            Assert.IsTrue(visualController.IsTouchingExposedForTest, "Should remain true.");

            visualController.OnShift(new Point(4, 4));
            Assert.IsTrue(visualController.IsTouchingExposedForTest, "Still should remain true.");

            visualController.OnUntouched(new Point(4, 5));
            Assert.IsFalse(visualController.IsTouchingExposedForTest, "Should be reset to false - no matter how many OnTouched has occurred before.");
        }