@@ -45,7 +45,7 @@ public async Task ICommand_Execute_StringParameter_Test(string parameter)
4545 }
4646
4747 [ Test ]
48- public async Task ICommand_TwoParameters_ExecuteAsync_InvalidValueTypeParameter_Test ( )
48+ public void ICommand_TwoParameters_ExecuteAsync_InvalidValueTypeParameter_Test ( )
4949 {
5050 //Arrange
5151 InvalidCommandParameterException ? actualInvalidCommandParameterException = null ;
@@ -54,24 +54,15 @@ public async Task ICommand_TwoParameters_ExecuteAsync_InvalidValueTypeParameter_
5454 ICommand command = new AsyncCommand < string , string > ( StringParameterTask ) ;
5555
5656 //Act
57- try
58- {
59- command . Execute ( Delay ) ;
60- await NoParameterTask ( ) ;
61- await NoParameterTask ( ) ;
62- }
63- catch ( InvalidCommandParameterException e )
64- {
65- actualInvalidCommandParameterException = e ;
66- }
57+ actualInvalidCommandParameterException = Assert . Throws < InvalidCommandParameterException > ( ( ) => command . Execute ( Delay ) ) ;
6758
6859 //Assert
6960 Assert . IsNotNull ( actualInvalidCommandParameterException ) ;
7061 Assert . AreEqual ( expectedInvalidCommandParameterException . Message , actualInvalidCommandParameterException ? . Message ) ;
7162 }
7263
7364 [ Test ]
74- public async Task ICommand_ExecuteAsync_InvalidValueTypeParameter_Test ( )
65+ public void ICommand_ExecuteAsync_InvalidValueTypeParameter_Test ( )
7566 {
7667 //Arrange
7768 InvalidCommandParameterException ? actualInvalidCommandParameterException = null ;
@@ -80,24 +71,15 @@ public async Task ICommand_ExecuteAsync_InvalidValueTypeParameter_Test()
8071 ICommand command = new AsyncCommand < string > ( StringParameterTask ) ;
8172
8273 //Act
83- try
84- {
85- command . Execute ( Delay ) ;
86- await NoParameterTask ( ) ;
87- await NoParameterTask ( ) ;
88- }
89- catch ( InvalidCommandParameterException e )
90- {
91- actualInvalidCommandParameterException = e ;
92- }
74+ actualInvalidCommandParameterException = Assert . Throws < InvalidCommandParameterException > ( ( ) => command . Execute ( Delay ) ) ;
9375
9476 //Assert
9577 Assert . IsNotNull ( actualInvalidCommandParameterException ) ;
9678 Assert . AreEqual ( expectedInvalidCommandParameterException . Message , actualInvalidCommandParameterException ? . Message ) ;
9779 }
9880
9981 [ Test ]
100- public async Task ICommand_TwoParameters_ExecuteAsync_InvalidReferenceTypeParameter_Test ( )
82+ public void ICommand_TwoParameters_ExecuteAsync_InvalidReferenceTypeParameter_Test ( )
10183 {
10284 //Arrange
10385 InvalidCommandParameterException ? actualInvalidCommandParameterException = null ;
@@ -107,24 +89,15 @@ public async Task ICommand_TwoParameters_ExecuteAsync_InvalidReferenceTypeParame
10789 ICommand command = new AsyncCommand < int , int > ( IntParameterTask ) ;
10890
10991 //Act
110- try
111- {
112- command . Execute ( "Hello World" ) ;
113- await NoParameterTask ( ) ;
114- await NoParameterTask ( ) ;
115- }
116- catch ( InvalidCommandParameterException e )
117- {
118- actualInvalidCommandParameterException = e ;
119- }
92+ actualInvalidCommandParameterException = Assert . Throws < InvalidCommandParameterException > ( ( ) => command . Execute ( "Hello World" ) ) ;
12093
12194 //Assert
12295 Assert . IsNotNull ( actualInvalidCommandParameterException ) ;
12396 Assert . AreEqual ( expectedInvalidCommandParameterException . Message , actualInvalidCommandParameterException ? . Message ) ;
12497 }
12598
12699 [ Test ]
127- public async Task ICommand_ExecuteAsync_InvalidReferenceTypeParameter_Test ( )
100+ public void ICommand_ExecuteAsync_InvalidReferenceTypeParameter_Test ( )
128101 {
129102 //Arrange
130103 InvalidCommandParameterException ? actualInvalidCommandParameterException = null ;
@@ -134,24 +107,15 @@ public async Task ICommand_ExecuteAsync_InvalidReferenceTypeParameter_Test()
134107 ICommand command = new AsyncCommand < int > ( IntParameterTask ) ;
135108
136109 //Act
137- try
138- {
139- command . Execute ( "Hello World" ) ;
140- await NoParameterTask ( ) ;
141- await NoParameterTask ( ) ;
142- }
143- catch ( InvalidCommandParameterException e )
144- {
145- actualInvalidCommandParameterException = e ;
146- }
110+ actualInvalidCommandParameterException = Assert . Throws < InvalidCommandParameterException > ( ( ) => command . Execute ( "Hello World" ) ) ;
147111
148112 //Assert
149113 Assert . IsNotNull ( actualInvalidCommandParameterException ) ;
150114 Assert . AreEqual ( expectedInvalidCommandParameterException . Message , actualInvalidCommandParameterException ? . Message ) ;
151115 }
152116
153117 [ Test ]
154- public async Task ICommand_TwoParameters_ExecuteAsync_ValueTypeParameter_Test ( )
118+ public void ICommand_TwoParameters_ExecuteAsync_ValueTypeParameter_Test ( )
155119 {
156120 //Arrange
157121 InvalidCommandParameterException ? actualInvalidCommandParameterException = null ;
@@ -161,24 +125,15 @@ public async Task ICommand_TwoParameters_ExecuteAsync_ValueTypeParameter_Test()
161125 ICommand command = new AsyncCommand < int , int > ( IntParameterTask ) ;
162126
163127 //Act
164- try
165- {
166- command . Execute ( null ) ;
167- await NoParameterTask ( ) ;
168- await NoParameterTask ( ) ;
169- }
170- catch ( InvalidCommandParameterException e )
171- {
172- actualInvalidCommandParameterException = e ;
173- }
128+ actualInvalidCommandParameterException = Assert . Throws < InvalidCommandParameterException > ( ( ) => command . Execute ( null ) ) ;
174129
175130 //Assert
176131 Assert . IsNotNull ( actualInvalidCommandParameterException ) ;
177132 Assert . AreEqual ( expectedInvalidCommandParameterException . Message , actualInvalidCommandParameterException ? . Message ) ;
178133 }
179134
180135 [ Test ]
181- public async Task ICommand_ExecuteAsync_ValueTypeParameter_Test ( )
136+ public void ICommand_ExecuteAsync_ValueTypeParameter_Test ( )
182137 {
183138 //Arrange
184139 InvalidCommandParameterException ? actualInvalidCommandParameterException = null ;
@@ -188,16 +143,7 @@ public async Task ICommand_ExecuteAsync_ValueTypeParameter_Test()
188143 ICommand command = new AsyncCommand < int > ( IntParameterTask ) ;
189144
190145 //Act
191- try
192- {
193- command . Execute ( null ) ;
194- await NoParameterTask ( ) ;
195- await NoParameterTask ( ) ;
196- }
197- catch ( InvalidCommandParameterException e )
198- {
199- actualInvalidCommandParameterException = e ;
200- }
146+ actualInvalidCommandParameterException = Assert . Throws < InvalidCommandParameterException > ( ( ) => command . Execute ( null ) ) ;
201147
202148 //Assert
203149 Assert . IsNotNull ( actualInvalidCommandParameterException ) ;
@@ -208,7 +154,7 @@ public async Task ICommand_ExecuteAsync_ValueTypeParameter_Test()
208154 public void ICommand_Parameter_CanExecuteTrue_Test ( )
209155 {
210156 //Arrange
211- ICommand command = new AsyncCommand < int > ( IntParameterTask , CanExecuteTrue ) ;
157+ ICommand command = new AsyncCommand < int ? > ( NullableIntParameterTask , CanExecuteTrue ) ;
212158 ICommand command2 = new AsyncCommand < int , int > ( IntParameterTask , CanExecuteTrue ) ;
213159
214160 //Act
@@ -222,7 +168,7 @@ public void ICommand_Parameter_CanExecuteTrue_Test()
222168 public void ICommand_Parameter_CanExecuteFalse_Test ( )
223169 {
224170 //Arrange
225- ICommand command = new AsyncCommand < int > ( IntParameterTask , CanExecuteFalse ) ;
171+ ICommand command = new AsyncCommand < int ? > ( NullableIntParameterTask , CanExecuteFalse ) ;
226172 ICommand command2 = new AsyncCommand < int , int > ( IntParameterTask , CanExecuteFalse ) ;
227173
228174 //Act
@@ -232,6 +178,40 @@ public void ICommand_Parameter_CanExecuteFalse_Test()
232178 Assert . False ( command2 . CanExecute ( 0 ) ) ;
233179 }
234180
181+ [ Test ]
182+ public void ICommand_Parameter_CanExecuteNull_Test ( )
183+ {
184+ //Arrange
185+ InvalidCommandParameterException ? actualInvalidCommandParameterException = null ;
186+ InvalidCommandParameterException expectedInvalidCommandParameterException = new InvalidCommandParameterException ( typeof ( int ) ) ;
187+
188+ ICommand command = new AsyncCommand < int , int > ( IntParameterTask , CanExecuteFalse ) ;
189+
190+ //Act
191+ actualInvalidCommandParameterException = Assert . Throws < InvalidCommandParameterException > ( ( ) => command . CanExecute ( null ) ) ;
192+
193+ //Assert
194+ Assert . IsNotNull ( actualInvalidCommandParameterException ) ;
195+ Assert . AreEqual ( expectedInvalidCommandParameterException . Message , actualInvalidCommandParameterException ? . Message ) ;
196+ }
197+
198+ [ Test ]
199+ public void ICommand_Parameter_ExecuteNull_Test ( )
200+ {
201+ //Arrange
202+ InvalidCommandParameterException ? actualInvalidCommandParameterException = null ;
203+ InvalidCommandParameterException expectedInvalidCommandParameterException = new InvalidCommandParameterException ( typeof ( int ) ) ;
204+
205+ ICommand command = new AsyncCommand < int , int > ( IntParameterTask , CanExecuteFalse ) ;
206+
207+ //Act
208+ actualInvalidCommandParameterException = Assert . Throws < InvalidCommandParameterException > ( ( ) => command . Execute ( null ) ) ;
209+
210+ //Assert
211+ Assert . IsNotNull ( actualInvalidCommandParameterException ) ;
212+ Assert . AreEqual ( expectedInvalidCommandParameterException . Message , actualInvalidCommandParameterException ? . Message ) ;
213+ }
214+
235215 [ Test ]
236216 public void ICommand_NoParameter_CanExecuteFalse_Test ( )
237217 {
0 commit comments