@@ -322,19 +322,21 @@ public void GetSlotData_should_return_slot_data_for_current_player_slot()
322322 Assert . That ( slotData [ "Two" ] , Is . EqualTo ( 2 ) ) ;
323323 }
324324
325- private class CustomSlotDataModel
325+ class CustomSlotDataModel
326326 {
327327 public class Options
328328 {
329329 public bool IsXRandomized { get ; set ; }
330330 public bool IsYRandomized { get ; set ; }
331331 }
332+ // ReSharper disable UnusedAutoPropertyAccessor.Local
332333 public int One { get ; set ; }
333334 public long Two { get ; set ; }
334335 public uint ? Three { get ; set ; }
335336 [ JsonProperty ( "ListOfStuff" ) ]
336337 public List < string > Strings { get ; set ; }
337338 public Options SlotOptions { get ; set ; }
339+ // ReSharper restore UnusedAutoPropertyAccessor.Local
338340 }
339341 [ Test ]
340342 public void GetSlotData_should_deserialize_custom_type_for_current_player_slot ( )
@@ -351,7 +353,7 @@ public void GetSlotData_should_deserialize_custom_type_for_current_player_slot()
351353 {
352354 { "One" , 1 } ,
353355 { "Two" , 2 } ,
354- { "ListOfStuff" , new string [ ] { "A" , "B" , "C" } } ,
356+ { "ListOfStuff" , new [ ] { "A" , "B" , "C" } } ,
355357 { "SlotOptions" , new CustomSlotDataModel . Options
356358 {
357359 IsXRandomized = true ,
@@ -943,6 +945,64 @@ public void GetClientStatusAsync_should_return_unknown_for_non_existing_slot()
943945 Assert . That ( statusBySlotAndTeam , Is . EqualTo ( ArchipelagoClientState . ClientUnknown ) ) ;
944946 }
945947
948+ [ Test ]
949+ public void GetRaceMode_should_return_race_mode ( )
950+ {
951+ var socket = Substitute . For < IArchipelagoSocketHelper > ( ) ;
952+ var connectionInfo = Substitute . For < IConnectionInfoProvider > ( ) ;
953+ //connectionInfo.Slot.Returns(8);
954+ //connectionInfo.Team.Returns(2);
955+
956+ var sut = new DataStorageHelper ( socket , connectionInfo ) ;
957+
958+ bool raceMode = false ;
959+
960+ ExecuteAsyncWithDelay (
961+ ( ) => { raceMode = sut . GetRaceMode ( ) ; } ,
962+ ( ) => RaiseRetrieved ( socket , "_read_race_mode" , new JValue ( true ) ) ) ;
963+
964+ socket . Received ( ) . SendPacketAsync ( Arg . Is < GetPacket > ( p => p . Keys . FirstOrDefault ( ) == "_read_race_mode" ) ) ;
965+
966+ Assert . IsTrue ( raceMode ) ;
967+ }
968+
969+ [ Test ]
970+ public void GetRaceModeAsync_should_return_race_mode ( )
971+ {
972+ var socket = Substitute . For < IArchipelagoSocketHelper > ( ) ;
973+ var connectionInfo = Substitute . For < IConnectionInfoProvider > ( ) ;
974+ //connectionInfo.Slot.Returns(7);
975+ //connectionInfo.Team.Returns(3);
976+
977+ var sut = new DataStorageHelper ( socket , connectionInfo ) ;
978+
979+ bool raceMode = false ;
980+
981+ #if NET471
982+ bool statusCallbackReceived = false ;
983+
984+ ExecuteAsyncWithDelay (
985+ ( ) => {
986+ sut . GetRaceModeAsync ( t => {
987+ statusCallbackReceived = true ;
988+ raceMode = t ;
989+ } ) ;
990+ } ,
991+ ( ) => RaiseRetrieved ( socket , "_read_race_mode" , new JValue ( true ) ) ) ;
992+
993+ while ( ! statusCallbackReceived )
994+ Thread . Sleep ( 10 ) ;
995+ #else
996+ ExecuteAsyncWithDelay (
997+ ( ) => { raceMode = sut . GetRaceModeAsync ( ) . Result ; } ,
998+ ( ) => RaiseRetrieved ( socket , "_read_race_mode" , new JValue ( true ) ) ) ;
999+ #endif
1000+
1001+ socket . Received ( ) . SendPacketAsync ( Arg . Is < GetPacket > ( p => p . Keys . FirstOrDefault ( ) == "_read_race_mode" ) ) ;
1002+
1003+ Assert . IsTrue ( raceMode ) ;
1004+ }
1005+
9461006 public static void ExecuteAsyncWithDelay ( Action retrieve , Action raiseEvent )
9471007 {
9481008 Task . WaitAll ( new [ ] {
0 commit comments