@@ -44,25 +44,69 @@ public class KeyTests
4444 public void Setup ( )
4545 {
4646 providerMock = new Mock < IKeyInputProvider > ( ) ;
47- providerMock . SetupSequence ( o => o . GetState ( ) )
48- . Returns ( new KeyboardState ( Keys . A , Keys . LeftShift , Keys . LeftControl , Keys . LeftAlt ) )
49- . Returns ( new KeyboardState ( Keys . B ) ) . Returns ( new KeyboardState ( Keys . C ) )
50- . Returns ( new KeyboardState ( Keys . D ) ) ;
51-
5247 input = new InputManager ( providerMock . Object , null , null , null ) ;
5348 }
5449
5550 [ Test ]
56- public void TestMocking ( )
51+ public void KeyDownPressAndReleaseWorkAndAreInSquence ( )
5752 {
58- input . Update ( ) ;
53+ providerMock . SetupSequence ( o => o . GetState ( ) )
54+ . Returns ( new KeyboardState ( Keys . A ) )
55+ . Returns ( new KeyboardState ( Keys . B ) )
56+ . Returns ( new KeyboardState ( Keys . C ) )
57+ . Returns ( new KeyboardState ( Keys . C ) ) ;
58+
59+ input . Update ( ) ;
5960 Assert . IsTrue ( input . Key . Is . Down ( Keys . A ) ) ;
61+ Assert . IsFalse ( input . Key . Is . Down ( Keys . B ) ) ;
62+ Assert . IsFalse ( input . Key . Is . Down ( Keys . C ) ) ;
63+
64+ Assert . IsTrue ( input . Key . Is . Press ( Keys . A ) ) ;
65+ Assert . IsFalse ( input . Key . Is . Press ( Keys . B ) ) ;
66+ Assert . IsFalse ( input . Key . Is . Press ( Keys . C ) ) ;
67+
68+ Assert . IsFalse ( input . Key . Is . Release ( Keys . A ) ) ;
69+ Assert . IsFalse ( input . Key . Is . Release ( Keys . B ) ) ;
70+ Assert . IsFalse ( input . Key . Is . Release ( Keys . C ) ) ;
71+
6072 input . Update ( ) ;
73+ Assert . IsFalse ( input . Key . Is . Down ( Keys . A ) ) ;
6174 Assert . IsTrue ( input . Key . Is . Down ( Keys . B ) ) ;
75+ Assert . IsFalse ( input . Key . Is . Down ( Keys . C ) ) ;
76+
77+ Assert . IsFalse ( input . Key . Is . Press ( Keys . A ) ) ;
78+ Assert . IsTrue ( input . Key . Is . Press ( Keys . B ) ) ;
79+ Assert . IsFalse ( input . Key . Is . Press ( Keys . C ) ) ;
80+
81+ Assert . IsTrue ( input . Key . Is . Release ( Keys . A ) ) ;
82+ Assert . IsFalse ( input . Key . Is . Release ( Keys . B ) ) ;
83+ Assert . IsFalse ( input . Key . Is . Release ( Keys . C ) ) ;
84+
6285 input . Update ( ) ;
86+ Assert . IsFalse ( input . Key . Is . Down ( Keys . A ) ) ;
87+ Assert . IsFalse ( input . Key . Is . Down ( Keys . B ) ) ;
6388 Assert . IsTrue ( input . Key . Is . Down ( Keys . C ) ) ;
89+
90+ Assert . IsFalse ( input . Key . Is . Press ( Keys . A ) ) ;
91+ Assert . IsFalse ( input . Key . Is . Press ( Keys . B ) ) ;
92+ Assert . IsTrue ( input . Key . Is . Press ( Keys . C ) ) ;
93+
94+ Assert . IsFalse ( input . Key . Is . Release ( Keys . A ) ) ;
95+ Assert . IsTrue ( input . Key . Is . Release ( Keys . B ) ) ;
96+ Assert . IsFalse ( input . Key . Is . Release ( Keys . C ) ) ;
97+
6498 input . Update ( ) ;
65- Assert . IsTrue ( input . Key . Is . Down ( Keys . D ) ) ;
99+ Assert . IsFalse ( input . Key . Is . Down ( Keys . A ) ) ;
100+ Assert . IsFalse ( input . Key . Is . Down ( Keys . B ) ) ;
101+ Assert . IsTrue ( input . Key . Is . Down ( Keys . C ) ) ;
102+
103+ Assert . IsFalse ( input . Key . Is . Press ( Keys . A ) ) ;
104+ Assert . IsFalse ( input . Key . Is . Press ( Keys . B ) ) ;
105+ Assert . IsFalse ( input . Key . Is . Press ( Keys . C ) ) ;
106+
107+ Assert . IsFalse ( input . Key . Is . Release ( Keys . A ) ) ;
108+ Assert . IsFalse ( input . Key . Is . Release ( Keys . B ) ) ;
109+ Assert . IsFalse ( input . Key . Is . Release ( Keys . C ) ) ;
66110 }
67111 }
68112}
0 commit comments