public void Serialize_Deserialize_MiniGame() { Random randomness_provider = new Random(); List <int> roles_list = new List <int>() { PD_Player_Roles.Operations_Expert, PD_Player_Roles.Researcher, PD_Player_Roles.Medic, PD_Player_Roles.Scientist }; for (int i = 0; i < 2000; i++) { // create a normal game, for later use PD_Game initial_game = PD_Game.Create_Game__AvailableRolesList( randomness_provider, 4, 0, roles_list ); // convert to mini game PD_MiniGame converted_mini_game = initial_game.Convert_To_MiniGame(); // serialize the mini game string serialized_mini_game = converted_mini_game.To_Json_String( Formatting.None, TypeNameHandling.None, PreserveReferencesHandling.None ); // deserialize the mini game PD_MiniGame deserialized_mini_game = JsonConvert.DeserializeObject <PD_MiniGame>(serialized_mini_game); // test that the deserialized game is exactly the same as the mini game Assert.IsTrue(converted_mini_game.GetHashCode() == deserialized_mini_game.GetHashCode()); Assert.IsTrue(converted_mini_game == deserialized_mini_game); Assert.IsTrue(converted_mini_game.Equals(deserialized_mini_game)); // create a normal game, from the deserialized game PD_Game final_game = deserialized_mini_game.Convert_To_Game(); Assert.IsTrue( Games_Practically_Equal( initial_game, final_game ) ); final_game.UpdateAvailablePlayerActions(); randomness_provider = new Random(i); while (final_game.GQ_Is_Ongoing()) { PD_Action action = final_game .CurrentAvailablePlayerActions .GetOneRandom(randomness_provider); final_game.Apply_Action( randomness_provider, action ); } randomness_provider = new Random(i); while (initial_game.GQ_Is_Ongoing()) { var action = initial_game.CurrentAvailablePlayerActions.GetOneRandom(randomness_provider); initial_game.Apply_Action( randomness_provider, action); } Assert.IsTrue(Games_Practically_Equal(initial_game, final_game)); } }