/// <summary>Builds a touch state from the current touches</summary>
        /// <returns>The currently mocked touches in a touch state</returns>
        private TouchState buildState()
        {
            var state = new TouchState(this.isAttached, this.touchCollection);

            TouchCollectionHelper.Clear(ref this.touchCollection);
            return(state);
        }
Beispiel #2
0
        public void TestSetLocationCount()
        {
            var touches = new TouchCollection();

            Assert.AreEqual(0, touches.Count);
            TouchCollectionHelper.SetLocationCount(ref touches, 2);
            Assert.AreEqual(2, touches.Count);
        }
 /// <summary>Moves an existing touch to a different location</summary>
 /// <param name="id">Id of the touch that will be moved</param>
 /// <param name="x">New X coordinate the touch moved to</param>
 /// <param name="y">New Y coordinate the touch moved to</param>
 public void Move(int id, float x, float y)
 {
     TouchCollectionHelper.AddTouchLocation(
         ref this.touchCollection,
         id,
         TouchLocationState.Moved,
         x,
         y,
         TouchLocationState.Invalid,
         -1.0f,
         -1.0f
         );
 }
 /// <summary>Releases the touch with the specified id</summary>
 /// <param name="id">Id of the touch that will be released</param>
 public void Release(int id)
 {
     TouchCollectionHelper.AddTouchLocation(
         ref this.touchCollection,
         id,
         TouchLocationState.Released,
         -1.0f,
         -1.0f,
         TouchLocationState.Invalid,
         -1.0f,
         -1.0f
         );
 }
Beispiel #5
0
        public void TestAddTouchLocation()
        {
            var touches = new TouchCollection();

            TouchCollectionHelper.AddTouchLocation(
                ref touches, 1,
                TouchLocationState.Pressed, 12, 34,
                TouchLocationState.Released, 56, 78
                );

            Assert.AreEqual(1, touches.Count);

            TouchLocation location = touches[0];

            Assert.AreEqual(12, location.Position.X);
            Assert.AreEqual(34, location.Position.Y);
            Assert.AreEqual(TouchLocationState.Pressed, location.State);
            Assert.AreEqual(1, location.Id);
        }