11using System . Collections . Concurrent ;
2+ using System . Reflection ;
23
34namespace RDMSharpTests
45{
@@ -208,17 +209,50 @@ public void TestSlot()
208209 var slot = new Slot ( 1 ) ;
209210 Assert . That ( slot . SlotId , Is . EqualTo ( 1 ) ) ;
210211
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 ) ! ;
211215 Assert . Multiple ( ( ) =>
212216 {
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+ } ) ;
216250 } ) ;
217251 Assert . Multiple ( ( ) =>
218252 {
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" ) } ) ; } ) ;
222256 Assert . That ( slot . DefaultValue , Is . EqualTo ( 200 ) ) ;
223257 Assert . That ( slot . Type , Is . EqualTo ( ERDM_SlotType . SEC_TIMING ) ) ;
224258 Assert . That ( slot . Category , Is . EqualTo ( ERDM_SlotCategory . CIE_X ) ) ;
@@ -230,9 +264,9 @@ public void TestSlot()
230264 {
231265 Assert . Multiple ( ( ) =>
232266 {
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" ) } ) ; } ) ;
236270 Assert . That ( fired , Is . EqualTo ( 4 ) ) ;
237271 Assert . That ( slot . DefaultValue , Is . EqualTo ( 100 ) ) ;
238272 Assert . That ( slot . Type , Is . EqualTo ( ERDM_SlotType . PRIMARY ) ) ;
0 commit comments