@@ -56,6 +56,24 @@ public void KeyDownTriggers()
5656 Assert . IsTrue ( input . Key . Is . Down ( Keys . A ) ) ;
5757 }
5858
59+ [ Test ]
60+ public void KeyDownMultipleInputsTriggers ( )
61+ {
62+ providerMock . SetupSequence ( o => o . GetState ( ) )
63+ . Returns ( new KeyboardState ( Keys . A , Keys . B ) ) ;
64+ input . Update ( ) ;
65+ Assert . IsTrue ( input . Key . Is . Down ( Keys . A , Keys . B ) ) ;
66+ }
67+
68+ [ Test ]
69+ public void KeyOneDownTriggers ( )
70+ {
71+ providerMock . SetupSequence ( o => o . GetState ( ) )
72+ . Returns ( new KeyboardState ( Keys . A ) ) ;
73+ input . Update ( ) ;
74+ Assert . IsTrue ( input . Key . Is . OneDown ( Keys . A , Keys . B ) ) ;
75+ }
76+
5977 [ Test ]
6078 public void KeyDownIsResetProperly ( )
6179 {
@@ -83,6 +101,30 @@ public void KeyUpTriggers()
83101 Assert . IsTrue ( input . Key . Is . Up ( Keys . A ) ) ;
84102 }
85103
104+ [ Test ]
105+ public void KeyUpMultipleInputsTriggers ( )
106+ {
107+ providerMock . SetupSequence ( o => o . GetState ( ) )
108+ . Returns ( new KeyboardState ( Keys . A , Keys . B ) )
109+ . Returns ( new KeyboardState ( ) ) ;
110+ input . Update ( ) ;
111+ Assert . IsFalse ( input . Key . Is . Up ( Keys . A , Keys . B ) ) ;
112+ input . Update ( ) ;
113+ Assert . IsTrue ( input . Key . Is . Up ( Keys . A , Keys . B ) ) ;
114+ }
115+
116+ [ Test ]
117+ public void KeyOneUpTriggers ( )
118+ {
119+ providerMock . SetupSequence ( o => o . GetState ( ) )
120+ . Returns ( new KeyboardState ( Keys . A ) )
121+ . Returns ( new KeyboardState ( ) ) ;
122+ input . Update ( ) ;
123+ Assert . IsTrue ( input . Key . Is . OneUp ( Keys . A , Keys . B ) ) ;
124+ input . Update ( ) ;
125+ Assert . IsTrue ( input . Key . Is . OneUp ( Keys . A , Keys . B ) ) ;
126+ }
127+
86128 [ Test ]
87129 public void KeyUpIsResetProperly ( )
88130 {
@@ -189,6 +231,34 @@ public void WasUpGivesOldState()
189231 Assert . IsFalse ( input . Key . Was . Up ( Keys . A ) ) ;
190232 }
191233
234+ [ Test ]
235+ public void WasDownGivesOldStateMultipleInputs ( )
236+ {
237+ providerMock . SetupSequence ( o => o . GetState ( ) )
238+ . Returns ( new KeyboardState ( Keys . A , Keys . B ) )
239+ . Returns ( new KeyboardState ( ) ) ;
240+ input . Update ( ) ;
241+ Assert . IsTrue ( input . Key . Is . Down ( Keys . A , Keys . B ) ) ;
242+ Assert . IsFalse ( input . Key . Was . Down ( Keys . A , Keys . B ) ) ;
243+ input . Update ( ) ;
244+ Assert . IsFalse ( input . Key . Is . Down ( Keys . A , Keys . B ) ) ;
245+ Assert . IsTrue ( input . Key . Was . Down ( Keys . A , Keys . B ) ) ;
246+ }
247+
248+ [ Test ]
249+ public void WasUpGivesOldStateMultipleInputs ( )
250+ {
251+ providerMock . SetupSequence ( o => o . GetState ( ) )
252+ . Returns ( new KeyboardState ( Keys . A , Keys . B ) )
253+ . Returns ( new KeyboardState ( ) ) ;
254+ input . Update ( ) ;
255+ Assert . IsFalse ( input . Key . Is . Up ( Keys . A , Keys . B ) ) ;
256+ Assert . IsTrue ( input . Key . Was . Up ( Keys . A , Keys . B ) ) ;
257+ input . Update ( ) ;
258+ Assert . IsTrue ( input . Key . Is . Up ( Keys . A , Keys . B ) ) ;
259+ Assert . IsFalse ( input . Key . Was . Up ( Keys . A , Keys . B ) ) ;
260+ }
261+
192262 [ Test ]
193263 public void AltPressIsTriggeredAndReleasedWithLeftAndRightAlt ( )
194264 {
@@ -288,6 +358,7 @@ public void CapslockPressIsTriggeredAndReleased()
288358 Assert . IsTrue ( input . Key . Is . CapsLockDown ) ;
289359 input . Update ( ) ;
290360 Assert . IsFalse ( input . Key . Is . CapsLockPress ) ;
361+ Assert . IsTrue ( input . Key . Is . CapsLockRelease ) ;
291362 Assert . IsTrue ( input . Key . Is . CapsLockUp ) ;
292363 }
293364
@@ -306,7 +377,47 @@ public void NumlockPressIsTriggeredAndReleased()
306377 Assert . IsTrue ( input . Key . Is . NumLockDown ) ;
307378 input . Update ( ) ;
308379 Assert . IsFalse ( input . Key . Is . NumLockPress ) ;
380+ Assert . IsTrue ( input . Key . Is . NumLockRelease ) ;
309381 Assert . IsTrue ( input . Key . Is . NumLockUp ) ;
310382 }
383+
384+ [ Test ]
385+ public void PressAndReleaseWorksWithSeveralKeys ( )
386+ {
387+ providerMock . SetupSequence ( o => o . GetState ( ) )
388+ . Returns ( new KeyboardState ( Keys . A , Keys . B ) )
389+ . Returns ( new KeyboardState ( Keys . A ) ) ;
390+ input . Update ( ) ;
391+ Assert . IsTrue ( input . Key . Is . Press ( Keys . A , Keys . B ) ) ;
392+ Assert . IsFalse ( input . Key . Is . Release ( Keys . A , Keys . B ) ) ;
393+ input . Update ( ) ;
394+ Assert . IsFalse ( input . Key . Is . Press ( Keys . A , Keys . B ) ) ;
395+ Assert . IsFalse ( input . Key . Is . Release ( Keys . A , Keys . B ) ) ;
396+ input . Update ( ) ;
397+ Assert . IsFalse ( input . Key . Is . Press ( Keys . A , Keys . B ) ) ;
398+ // A and B were not released at once.
399+ Assert . IsFalse ( input . Key . Is . Release ( Keys . A , Keys . B ) ) ;
400+ }
401+
402+ [ Test ]
403+ public void OnePressAndOneReleaseWorksWithSeveralKeys ( )
404+ {
405+ providerMock . SetupSequence ( o => o . GetState ( ) )
406+ . Returns ( new KeyboardState ( Keys . A ) )
407+ . Returns ( new KeyboardState ( Keys . A , Keys . B ) )
408+ . Returns ( new KeyboardState ( Keys . A ) ) ;
409+ input . Update ( ) ;
410+ Assert . IsTrue ( input . Key . Is . OnePress ( Keys . A , Keys . B ) ) ;
411+ Assert . IsFalse ( input . Key . Is . OneRelease ( Keys . A , Keys . B ) ) ;
412+ input . Update ( ) ;
413+ Assert . IsTrue ( input . Key . Is . OnePress ( Keys . A , Keys . B ) ) ;
414+ Assert . IsFalse ( input . Key . Is . OneRelease ( Keys . A , Keys . B ) ) ;
415+ input . Update ( ) ;
416+ Assert . IsFalse ( input . Key . Is . OnePress ( Keys . A , Keys . B ) ) ;
417+ Assert . IsTrue ( input . Key . Is . OneRelease ( Keys . A , Keys . B ) ) ;
418+ input . Update ( ) ;
419+ Assert . IsFalse ( input . Key . Is . OnePress ( Keys . A , Keys . B ) ) ;
420+ Assert . IsTrue ( input . Key . Is . OneRelease ( Keys . A , Keys . B ) ) ;
421+ }
311422 }
312423}
0 commit comments