1
1
using System . Collections . Concurrent ;
2
+ using System . Reflection ;
2
3
3
4
namespace RDMSharpTests
4
5
{
@@ -208,17 +209,50 @@ public void TestSlot()
208
209
var slot = new Slot ( 1 ) ;
209
210
Assert . That ( slot . SlotId , Is . EqualTo ( 1 ) ) ;
210
211
212
+ MethodInfo updateSlotDefaultValue = slot . GetType ( ) . GetMethod ( "UpdateSlotDefaultValue" , BindingFlags . NonPublic | BindingFlags . Instance ) ! ;
213
+ MethodInfo updateSlotInfo = slot . GetType ( ) . GetMethod ( "UpdateSlotInfo" , BindingFlags . NonPublic | BindingFlags . Instance ) ! ;
214
+ MethodInfo updateSlotDescription = slot . GetType ( ) . GetMethod ( "UpdateSlotDescription" , BindingFlags . NonPublic | BindingFlags . Instance ) ! ;
211
215
Assert . Multiple ( ( ) =>
212
216
{
213
- Assert . Throws ( typeof ( InvalidOperationException ) , ( ) => { slot . UpdateSlotDefaultValue ( new RDMDefaultSlotValue ( 2 ) ) ; } ) ;
214
- Assert . Throws ( typeof ( InvalidOperationException ) , ( ) => { slot . UpdateSlotInfo ( new RDMSlotInfo ( 2 ) ) ; } ) ;
215
- Assert . Throws ( typeof ( InvalidOperationException ) , ( ) => { slot . UpdateSlotDescription ( new RDMSlotDescription ( 2 ) ) ; } ) ;
217
+ Assert . Throws ( typeof ( InvalidOperationException ) , ( ) =>
218
+ {
219
+ try
220
+ {
221
+ updateSlotDefaultValue . Invoke ( slot , new object [ ] { new RDMDefaultSlotValue ( 2 ) } ) ;
222
+ }
223
+ catch ( TargetInvocationException t )
224
+ {
225
+ throw t . InnerException ;
226
+ }
227
+ } ) ;
228
+ Assert . Throws ( typeof ( InvalidOperationException ) , ( ) =>
229
+ {
230
+ try
231
+ {
232
+ updateSlotInfo . Invoke ( slot , new object [ ] { new RDMSlotInfo ( 2 ) } ) ;
233
+ }
234
+ catch ( TargetInvocationException t )
235
+ {
236
+ throw t . InnerException ;
237
+ }
238
+ } ) ;
239
+ Assert . Throws ( typeof ( InvalidOperationException ) , ( ) =>
240
+ {
241
+ try
242
+ {
243
+ updateSlotDescription . Invoke ( slot , new object [ ] { new RDMSlotDescription ( 2 ) } ) ;
244
+ }
245
+ catch ( TargetInvocationException t )
246
+ {
247
+ throw t . InnerException ;
248
+ }
249
+ } ) ;
216
250
} ) ;
217
251
Assert . Multiple ( ( ) =>
218
252
{
219
- Assert . DoesNotThrow ( ( ) => { slot . UpdateSlotDefaultValue ( new RDMDefaultSlotValue ( 1 , 200 ) ) ; } ) ;
220
- Assert . DoesNotThrow ( ( ) => { slot . UpdateSlotInfo ( new RDMSlotInfo ( 1 , ERDM_SlotType . SEC_TIMING , ERDM_SlotCategory . CIE_X ) ) ; } ) ;
221
- Assert . DoesNotThrow ( ( ) => { slot . UpdateSlotDescription ( new RDMSlotDescription ( 1 , "rrrr" ) ) ; } ) ;
253
+ Assert . DoesNotThrow ( ( ) => { updateSlotDefaultValue . Invoke ( slot , new object [ ] { new RDMDefaultSlotValue ( 1 , 200 ) } ) ; } ) ;
254
+ Assert . DoesNotThrow ( ( ) => { updateSlotInfo . Invoke ( slot , new object [ ] { new RDMSlotInfo ( 1 , ERDM_SlotType . SEC_TIMING , ERDM_SlotCategory . CIE_X ) } ) ; } ) ;
255
+ Assert . DoesNotThrow ( ( ) => { updateSlotDescription . Invoke ( slot , new object [ ] { new RDMSlotDescription ( 1 , "rrrr" ) } ) ; } ) ;
222
256
Assert . That ( slot . DefaultValue , Is . EqualTo ( 200 ) ) ;
223
257
Assert . That ( slot . Type , Is . EqualTo ( ERDM_SlotType . SEC_TIMING ) ) ;
224
258
Assert . That ( slot . Category , Is . EqualTo ( ERDM_SlotCategory . CIE_X ) ) ;
@@ -230,9 +264,9 @@ public void TestSlot()
230
264
{
231
265
Assert . Multiple ( ( ) =>
232
266
{
233
- Assert . DoesNotThrow ( ( ) => { slot . UpdateSlotDefaultValue ( new RDMDefaultSlotValue ( 1 , 100 ) ) ; } ) ;
234
- Assert . DoesNotThrow ( ( ) => { slot . UpdateSlotInfo ( new RDMSlotInfo ( 1 , ERDM_SlotType . PRIMARY , ERDM_SlotCategory . COLOR_SCROLL ) ) ; } ) ;
235
- Assert . DoesNotThrow ( ( ) => { slot . UpdateSlotDescription ( new RDMSlotDescription ( 1 , "aaa" ) ) ; } ) ;
267
+ Assert . DoesNotThrow ( ( ) => { updateSlotDefaultValue . Invoke ( slot , new object [ ] { new RDMDefaultSlotValue ( 1 , 100 ) } ) ; } ) ;
268
+ Assert . DoesNotThrow ( ( ) => { updateSlotInfo . Invoke ( slot , new object [ ] { new RDMSlotInfo ( 1 , ERDM_SlotType . PRIMARY , ERDM_SlotCategory . COLOR_SCROLL ) } ) ; } ) ;
269
+ Assert . DoesNotThrow ( ( ) => { updateSlotDescription . Invoke ( slot , new object [ ] { new RDMSlotDescription ( 1 , "aaa" ) } ) ; } ) ;
236
270
Assert . That ( fired , Is . EqualTo ( 4 ) ) ;
237
271
Assert . That ( slot . DefaultValue , Is . EqualTo ( 100 ) ) ;
238
272
Assert . That ( slot . Type , Is . EqualTo ( ERDM_SlotType . PRIMARY ) ) ;
0 commit comments