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 IEnumerator OutOfGameTime_UpdatesOnLoad( [ValueSource(nameof(RealSeconds))] double secondsOutOfGame ) { FortuneFountainSaveData fortuneFountainSaveData = FortuneFountainSaveData.NewSaveFile(nameof(OutOfGameTime_UpdatesOnLoad)); yield return(null); fortuneFountainSaveData.Save(false); var saveTime = FrameTime.Now; var outOfGameSpan = TimeSpan.FromSeconds(secondsOutOfGame); yield return(TestUtils.WaitForRealtime(outOfGameSpan)); var loadedSaveData = FortuneFountainSaveData.Load(fortuneFountainSaveData.Nickname); var loadTime = FrameTime.Now; Assert.That(loadedSaveData, Has.Property(nameof(loadedSaveData.OutOfGameTimeSinceLastThrow)).EqualTo(loadTime - saveTime)); }