@@ -45,35 +45,20 @@ internal static InputAction SetupTestAction(this InputActionMap map, string modi
4545
4646internal partial class CoreTests
4747{
48- private static IEnumerable < TwoInputActionDataWrapper < InputAction , InputAction > > TwoInputActionTestCases ( )
48+ private static IEnumerable < ( InputAction , InputAction ) > TwoInputActionTestCases ( )
4949 {
5050 InputActionMap map = new InputActionMap ( "map" ) ;
51- yield return new TwoInputActionDataWrapper < InputAction , InputAction >
52- {
53- Action1 = map . SetupTestAction ( "ctrl" , "x" ) ,
54- Action2 = map . SetupTestAction ( "x" )
55- } ;
56- yield return new TwoInputActionDataWrapper < InputAction , InputAction >
57- {
58- Action1 = map . SetupTestAction ( "shift" , "n" ) ,
59- Action2 = map . SetupTestAction ( "n" )
60- } ;
61- yield return new TwoInputActionDataWrapper < InputAction , InputAction >
62- {
63- Action1 = map . SetupTestAction ( "ctrl" , "shift" , "h" ) ,
64- Action2 = map . SetupTestAction ( "shift" , "h" )
65- } ;
66- yield return new TwoInputActionDataWrapper < InputAction , InputAction >
51+
52+ var cases = new List < ( InputAction , InputAction ) > ( )
6753 {
68- Action1 = map . SetupTestAction ( "ctrl" , "shift" , "v" ) ,
69- Action2 = map . SetupTestAction ( "shift" , "v" )
54+ ( map . SetupTestAction ( "ctrl" , "x" ) , map . SetupTestAction ( "x" ) ) ,
55+ ( map . SetupTestAction ( "shift" , "n" ) , map . SetupTestAction ( "n" ) ) ,
56+ ( map . SetupTestAction ( "ctrl" , "shift" , "h" ) , map . SetupTestAction ( "shift" , "h" ) ) ,
57+ ( map . SetupTestAction ( "ctrl" , "shift" , "v" ) , map . SetupTestAction ( "shift" , "v" ) )
7058 } ;
71- }
7259
73- public class TwoInputActionDataWrapper < TInputAction1 , TInputAction2 >
74- {
75- public TInputAction1 Action1 ;
76- public TInputAction2 Action2 ;
60+ foreach ( var c in cases )
61+ yield return c ;
7762 }
7863
7964 public class ThreeInputActionDataWrapper < TInputAction1 , TInputAction2 , TInputAction3 >
@@ -128,12 +113,11 @@ private void ReleaseBindingsForActions(Keyboard keyboard, InputAction action1, I
128113 [ Test ]
129114 [ Category ( "Actions Priority" ) ]
130115 [ TestCaseSource ( nameof ( TwoInputActionTestCases ) ) ]
131- public void Actions_Priority_OnlyOneActionIsFired_WhenOnePriorityIsHigherThanOther ( TwoInputActionDataWrapper < InputAction , InputAction > twoInputActions )
116+ public void Actions_Priority_OnlyOneActionIsFired_WhenOnePriorityIsHigherThanOther ( ( InputAction , InputAction ) twoInputActions )
132117 {
133118 var keyboard = InputSystem . AddDevice < Keyboard > ( ) ;
134119
135- var action1 = twoInputActions . Action1 ;
136- var action2 = twoInputActions . Action2 ;
120+ var ( action1 , action2 ) = twoInputActions ;
137121
138122 // action 1's priority higher so it takes precedence
139123 action1 . Priority = 2 ;
@@ -160,12 +144,11 @@ public void Actions_Priority_OnlyOneActionIsFired_WhenOnePriorityIsHigherThanOth
160144 [ Test ]
161145 [ Category ( "Actions Priority" ) ]
162146 [ TestCaseSource ( nameof ( TwoInputActionTestCases ) ) ]
163- public void Actions_Priority_OnlyOneActionIsFired_WhenOnePriorityIsHigherThanOtherInversePriorityOrder ( TwoInputActionDataWrapper < InputAction , InputAction > twoInputActions )
147+ public void Actions_Priority_OnlyOneActionIsFired_WhenOnePriorityIsHigherThanOtherInversePriorityOrder ( ( InputAction , InputAction ) actions )
164148 {
165149 var keyboard = InputSystem . AddDevice < Keyboard > ( ) ;
166150
167- var action1 = twoInputActions . Action1 ;
168- var action2 = twoInputActions . Action2 ;
151+ var ( action1 , action2 ) = actions ;
169152
170153 // action 2's priority higher so it takes precedence
171154 action1 . Priority = 1 ;
@@ -192,14 +175,13 @@ public void Actions_Priority_OnlyOneActionIsFired_WhenOnePriorityIsHigherThanOth
192175 [ Test ]
193176 [ Category ( "Actions Priority" ) ]
194177 [ TestCaseSource ( nameof ( TwoInputActionTestCases ) ) ] // TODO: Darren, Should both actions be performed this frame here??
195- public void Actions_Priority_BothActionsArePerformed_DueToKeyPressOrderForShortcut ( TwoInputActionDataWrapper < InputAction , InputAction > twoInputActions )
178+ public void Actions_Priority_BothActionsArePerformed_DueToKeyPressOrderForShortcut ( ( InputAction , InputAction ) actions )
196179 {
197180 var keyboard = InputSystem . AddDevice < Keyboard > ( ) ;
198181
199182 // We swap the order here of Action1 & Action2 so key presses are done backwards, binding before modifiers.
200183 // This causes the opposite keys foreach test case inside TwoInputActionTestCases to be pressed first.
201- var smallerBindingAction = twoInputActions . Action2 ;
202- var largerBindingAction = twoInputActions . Action1 ;
184+ var ( smallerBindingAction , largerBindingAction ) = actions ;
203185
204186 // Event though the priority is higher for action2 here, due to the order of the keys being pressed only Action1 will be fired.
205187 smallerBindingAction . Priority = 1 ;
@@ -229,12 +211,11 @@ public void Actions_Priority_BothActionsArePerformed_DueToKeyPressOrderForShortc
229211 [ Test ]
230212 [ Category ( "Actions Priority" ) ]
231213 [ TestCaseSource ( nameof ( TwoInputActionTestCases ) ) ]
232- public void Actions_Priority_BothActionFires_WhenPriorityIsEqual ( TwoInputActionDataWrapper < InputAction , InputAction > twoInputActions )
214+ public void Actions_Priority_BothActionFires_WhenPriorityIsEqual ( ( InputAction , InputAction ) actions )
233215 {
234216 var keyboard = InputSystem . AddDevice < Keyboard > ( ) ;
235217
236- var action1 = twoInputActions . Action1 ;
237- var action2 = twoInputActions . Action2 ;
218+ var ( action1 , action2 ) = actions ;
238219
239220 action1 . Priority = 5 ;
240221 action2 . Priority = 5 ;
@@ -250,12 +231,11 @@ public void Actions_Priority_BothActionFires_WhenPriorityIsEqual(TwoInputActionD
250231 [ Test ]
251232 [ Category ( "Actions Priority" ) ]
252233 [ TestCaseSource ( nameof ( TwoInputActionTestCases ) ) ]
253- public void Actions_Priority_BothActionsFire_WhenPriorityIsZero ( TwoInputActionDataWrapper < InputAction , InputAction > twoInputActions )
234+ public void Actions_Priority_BothActionsFire_WhenPriorityIsZero ( ( InputAction , InputAction ) actions )
254235 {
255236 var keyboard = InputSystem . AddDevice < Keyboard > ( ) ;
256237
257- var action1 = twoInputActions . Action1 ;
258- var action2 = twoInputActions . Action2 ;
238+ var ( action1 , action2 ) = actions ;
259239
260240 action1 . Priority = 0 ;
261241 action2 . Priority = 0 ;
@@ -273,40 +253,29 @@ public void Actions_Priority_BothActionsFire_WhenPriorityIsZero(TwoInputActionDa
273253 Assert . That ( action2WasPerformed , Is . True ) ;
274254 }
275255
276- private static IEnumerable < TwoInputActionDataWrapper < InputAction , InputAction > > TwoInputActionNoConflictingBindingTestCases ( )
256+ private static IEnumerable < ( InputAction , InputAction ) > TwoInputActionNoConflictingBindingTestCases ( )
277257 {
278258 InputActionMap map = new InputActionMap ( "map" ) ;
279- yield return new TwoInputActionDataWrapper < InputAction , InputAction >
280- {
281- Action1 = map . SetupTestAction ( "ctrl" , "x" ) ,
282- Action2 = map . SetupTestAction ( "k" )
283- } ;
284- yield return new TwoInputActionDataWrapper < InputAction , InputAction >
285- {
286- Action1 = map . SetupTestAction ( "shift" , "n" ) ,
287- Action2 = map . SetupTestAction ( "l" )
288- } ;
289- yield return new TwoInputActionDataWrapper < InputAction , InputAction >
290- {
291- Action1 = map . SetupTestAction ( "shift" , "h" ) ,
292- Action2 = map . SetupTestAction ( "ctrl" , "shift" , "o" )
293- } ;
294- yield return new TwoInputActionDataWrapper < InputAction , InputAction >
259+ var cases = new List < ( InputAction , InputAction ) > ( )
295260 {
296- Action1 = map . SetupTestAction ( "ctrl" , "shift" , "v" ) ,
297- Action2 = map . SetupTestAction ( "shift" , "z" )
261+ ( map . SetupTestAction ( "ctrl" , "x" ) , map . SetupTestAction ( "k" ) ) ,
262+ ( map . SetupTestAction ( "shift" , "n" ) , map . SetupTestAction ( "l" ) ) ,
263+ ( map . SetupTestAction ( "shift" , "h" ) , map . SetupTestAction ( "l" ) ) ,
264+ ( map . SetupTestAction ( "shift" , "h" ) , map . SetupTestAction ( "ctrl" , "shift" , "o" ) ) ,
265+ ( map . SetupTestAction ( "ctrl" , "shift" , "v" ) , map . SetupTestAction ( "shift" , "z" ) )
298266 } ;
267+ foreach ( var c in cases )
268+ yield return c ;
299269 }
300270
301271 [ Test ]
302272 [ Category ( "Actions Priority" ) ]
303273 [ TestCaseSource ( nameof ( TwoInputActionNoConflictingBindingTestCases ) ) ]
304- public void Actions_Priority_BothActionsWithDifferentPriorityFire_WhenThereIsNoConflictingBinding ( TwoInputActionDataWrapper < InputAction , InputAction > twoInputActions )
274+ public void Actions_Priority_BothActionsWithDifferentPriorityFire_WhenThereIsNoConflictingBinding ( ( InputAction , InputAction ) actions )
305275 {
306276 var keyboard = InputSystem . AddDevice < Keyboard > ( ) ;
307277
308- var action1 = twoInputActions . Action1 ;
309- var action2 = twoInputActions . Action2 ;
278+ var ( action1 , action2 ) = actions ;
310279
311280 action1 . Priority = 0 ;
312281 action2 . Priority = 1 ;
@@ -329,12 +298,11 @@ public void Actions_Priority_BothActionsWithDifferentPriorityFire_WhenThereIsNoC
329298 [ Test ]
330299 [ Category ( "Actions Priority" ) ]
331300 [ TestCaseSource ( nameof ( TwoInputActionNoConflictingBindingTestCases ) ) ]
332- public void Actions_Priority_BothActionsWithDifferentPriorityFire_WhenThereIsNoConflictingBindingInverseOrder ( TwoInputActionDataWrapper < InputAction , InputAction > twoInputActions )
301+ public void Actions_Priority_BothActionsWithDifferentPriorityFire_WhenThereIsNoConflictingBindingInverseOrder ( ( InputAction , InputAction ) actions )
333302 {
334303 var keyboard = InputSystem . AddDevice < Keyboard > ( ) ;
335304
336- var action1 = twoInputActions . Action1 ;
337- var action2 = twoInputActions . Action2 ;
305+ var ( action1 , action2 ) = actions ;
338306
339307 action1 . Priority = 15 ;
340308 action2 . Priority = 5 ;
@@ -357,12 +325,11 @@ public void Actions_Priority_BothActionsWithDifferentPriorityFire_WhenThereIsNoC
357325 [ Test ]
358326 [ Category ( "Actions Priority" ) ]
359327 [ TestCaseSource ( nameof ( TwoInputActionNoConflictingBindingTestCases ) ) ]
360- public void Actions_Priority_BothActionsWithEqualPriorityFire_WhenThereIsNoConflictingBinding ( TwoInputActionDataWrapper < InputAction , InputAction > twoInputActions )
328+ public void Actions_Priority_BothActionsWithEqualPriorityFire_WhenThereIsNoConflictingBinding ( ( InputAction , InputAction ) actions )
361329 {
362330 var keyboard = InputSystem . AddDevice < Keyboard > ( ) ;
363331
364- var action1 = twoInputActions . Action1 ;
365- var action2 = twoInputActions . Action2 ;
332+ var ( action1 , action2 ) = actions ;
366333
367334 action1 . Priority = 5 ;
368335 action2 . Priority = 5 ;
0 commit comments