1+ // ***************************************************************************
2+ // This is free and unencumbered software released into the public domain.
3+ //
4+ // Anyone is free to copy, modify, publish, use, compile, sell, or
5+ // distribute this software, either in source code form or as a compiled
6+ // binary, for any purpose, commercial or non-commercial, and by any
7+ // means.
8+ //
9+ // In jurisdictions that recognize copyright laws, the author or authors
10+ // of this software dedicate any and all copyright interest in the
11+ // software to the public domain. We make this dedication for the benefit
12+ // of the public at large and to the detriment of our heirs and
13+ // successors. We intend this dedication to be an overt act of
14+ // relinquishment in perpetuity of all present and future rights to this
15+ // software under copyright law.
16+ //
17+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20+ // IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21+ // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+ // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+ // OTHER DEALINGS IN THE SOFTWARE.
24+ //
25+ // For more information, please refer to <http://unlicense.org>
26+ // ***************************************************************************
27+
28+ using System ;
29+ using InputStateManager ;
30+ using InputStateManager . Inputs . InputProviders . Interfaces ;
31+ using Microsoft . Xna . Framework ;
32+ using Microsoft . Xna . Framework . Input . Touch ;
33+ using Moq ;
34+ using NUnit . Framework ;
35+
36+ namespace NUnitTests
37+ {
38+ [ TestFixture ]
39+ [ Category ( "InputStateManager.Mouse" ) ]
40+ public class TouchTests
41+ {
42+ private InputManager input ;
43+ private Mock < ITouchInputProvider > providerMock ;
44+
45+ [ SetUp ]
46+ public void Setup ( )
47+ {
48+ providerMock = new Mock < ITouchInputProvider > ( ) ;
49+ input = new InputManager ( null , null , null , providerMock . Object ) ;
50+ }
51+
52+ [ Test ]
53+ public void MouseTests ( )
54+ {
55+ providerMock . SetupSequence ( o => o . GetState ( ) )
56+ . Returns ( new TouchCollection ( ) ) ;
57+ providerMock . SetupSequence ( o => o . GetDisplayOrientation ( ) )
58+ . Returns ( DisplayOrientation . Default ) ;
59+ providerMock . SetupSequence ( o => o . GetDisplayHeight ( ) )
60+ . Returns ( 780 ) ;
61+ providerMock . SetupSequence ( o => o . GetDisplayWidth ( ) )
62+ . Returns ( 1280 ) ;
63+ providerMock . SetupSequence ( o => o . GetEnableMouseGestures ( ) )
64+ . Returns ( true ) ;
65+ providerMock . SetupSequence ( o => o . GetEnableMouseTouchPoint ( ) )
66+ . Returns ( true ) ;
67+ providerMock . SetupSequence ( o => o . GetEnabledGestures ( ) )
68+ . Returns ( GestureType . FreeDrag | GestureType . Flick ) ;
69+ providerMock . SetupSequence ( o => o . GetIsGestureAvailable ( ) )
70+ . Returns ( true ) ;
71+ providerMock . SetupSequence ( o => o . ReadGesture ( ) )
72+ . Returns ( new GestureSample ( GestureType . Hold , TimeSpan . FromMilliseconds ( 12 ) , Vector2 . Zero , Vector2 . Zero ,
73+ Vector2 . Zero , Vector2 . Zero ) ) ;
74+ input . Update ( ) ;
75+ Assert . IsTrue ( input . Touch . IsGestureAvailable ) ;
76+ }
77+ }
78+ }
0 commit comments