public void TestSerializeThrowables() { const string nickName = nameof(TestSerializeThrowables); FortuneFountainSaveData fortuneFountainSaveData = FortuneFountainSaveData.NewSaveFile(nickName); for (int i = 0; i < ValuableDatabase.ValuableTypes.Length; i++) { // copying `i` into `index` inside the loop 'cus otherwise lambdas can get messed up var index = i; var karmaValue = Random.Range(1, 25); var valuableType = ValuableDatabase.ValuableTypes[index]; Log($"Grabbing a {valuableType} with a value of {karmaValue}"); fortuneFountainSaveData.Hand.AddToHand(new ThrowableValuable(valuableType, karmaValue)); fortuneFountainSaveData.Save(useReSaveDelay: false); Log($"before loading throwables:", fortuneFountainSaveData.Hand.Throwables.JoinLines()); //load the save data we created FortuneFountainSaveData loadedSaveData = FortuneFountainSaveData.Load(nickName); Log($"original SaveData:", fortuneFountainSaveData); Log($"loaded SaveData:", loadedSaveData); AssertAll.Of( () => Assert.That(loadedSaveData.ToJson(), Contains.Substring($"\"{nameof(Hand._throwables)}\":")), () => Assert.That(loadedSaveData.Hand.Throwables.Count, Is.EqualTo(index + 1)), () => Assert.That(loadedSaveData.Hand.Throwables[index] as ThrowableValuable, Has.Property(nameof(ThrowableValuable.ValuableType)).EqualTo(valuableType)), () => Assert.That(loadedSaveData.Hand.Throwables[index] as ThrowableValuable, Has.Property(nameof(ThrowableValuable.PresentValue)).EqualTo(karmaValue)) ); } }
public void TestSerializeEmptyHand() { const string nickName = nameof(TestSerializeEmptyHand); FortuneFountainSaveData fortuneFountainSaveData = FortuneFountainSaveData.NewSaveFile(nickName); LogUtils.Log(fortuneFountainSaveData); Assert.That(fortuneFountainSaveData.ToJson(), Contains.Substring($"\"{nameof(Hand)}\": {{")); }