コード例 #1
0
        public void WhenPeopleIsRotatingThenZoomShouldNotBeTrigged()
        {
            var zoomRecognizer = new Mock<IGestureRecognizer>();
            var rotationRecognizer = new Mock<IRotationGripGesture>();

            rotationRecognizer.Setup(r => r.CurrentAngleDelta).Returns(20f);
            rotationRecognizer.Setup(r => r.IdentifyGesture(It.IsAny<UserSkeletonState>())).Returns(false);
            zoomRecognizer.Setup(z => z.IdentifyGesture(It.IsAny<UserSkeletonState>())).Returns(true);

            ZoomAndRotationGesture target = new ZoomAndRotationGesture(zoomRecognizer.Object, rotationRecognizer.Object);
            
            bool expected = false;
            bool actual = target.IdentifyGesture(null);

            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        public void WhenPeopleIsNotRotatingThenZoomCanBeTrigged()
        {
            var zoomRecognizer = new Mock<IGestureRecognizer>();
            var rotationRecognizer = new Mock<IRotationGripGesture>();

            rotationRecognizer.Setup(r => r.CurrentAngleDelta).Returns(0f);
            rotationRecognizer.Setup(r => r.IdentifyGesture(It.IsAny<UserSkeletonState>())).Returns(false);
            zoomRecognizer.Setup(z => z.IdentifyGesture(It.IsAny<UserSkeletonState>())).Returns(true);
            String eventName = GestureEvents.ZOOM_IN;
            zoomRecognizer.Setup(z => z.Name).Returns(eventName);

            ZoomAndRotationGesture target = new ZoomAndRotationGesture(zoomRecognizer.Object, rotationRecognizer.Object);

            bool expected = true;
            bool actual = target.IdentifyGesture(null);

            Assert.AreEqual(expected, actual);
            Assert.AreEqual(eventName, target.Name);
        }
コード例 #3
0
        public void GivenZoomWasIdentifiedWhenZoomStateIsResetedThenRotationCanBeFired()
        {
            var zoomRecognizer = new Mock<IGestureRecognizer>();
            var rotationRecognizer = new Mock<IRotationGripGesture>();

            ZoomAndRotationGesture target = new ZoomAndRotationGesture(zoomRecognizer.Object, rotationRecognizer.Object);

            rotationRecognizer.Setup(r => r.CurrentAngleDelta).Returns(0f);
            rotationRecognizer.Setup(r => r.IdentifyGesture(It.IsAny<UserSkeletonState>())).Returns(false);
            zoomRecognizer.Setup(z => z.IdentifyGesture(It.IsAny<UserSkeletonState>())).Returns(true);
            zoomRecognizer.Setup(z => z.State).Returns(1);
            String eventName = GestureEvents.ZOOM_IN;
            zoomRecognizer.Setup(z => z.Name).Returns(eventName);

            bool expected = true;
            bool actual = target.IdentifyGesture(null);

            Assert.AreEqual(expected, actual);
            Assert.AreEqual(eventName, target.Name);

            zoomRecognizer.Setup(z => z.IdentifyGesture(It.IsAny<UserSkeletonState>())).Returns(false);
            zoomRecognizer.Setup(z => z.State).Returns(0);

            expected = false;
            actual = target.IdentifyGesture(null);
            Assert.AreEqual(expected, actual);

            eventName = GestureEvents.ROTATE_RIGHT;
            rotationRecognizer.Setup(r => r.CurrentAngleDelta).Returns(65f);
            rotationRecognizer.Setup(r => r.IdentifyGesture(It.IsAny<UserSkeletonState>())).Returns(true);
            rotationRecognizer.Setup(z => z.Name).Returns(eventName);
            actual = target.IdentifyGesture(null);

            expected = true;
            Assert.AreEqual(expected, actual);
            Assert.AreEqual(eventName, target.Name);
        }