예제 #1
0
        public void LoadingMissingNickNameThrowsSaveDataException()
        {
            const string nickName = nameof(LoadingMissingNickNameThrowsSaveDataException);

            Assume.That(SaveDataTestImpl.GetAllSaveFilePaths(nickName), Is.Empty, $"Save files with the nickname {nickName} were found - please delete them, then run this test again.");

            Assert.Throws <SaveDataException>(() => SaveDataTestImpl.Load(nickName));
        }
예제 #2
0
        public IEnumerator TestLoadMostRecentSaveFile()
        {
            //save a few files
            const int    saveCount = 3;
            const string nickName  = nameof(TestLoadMostRecentSaveFile);

            //create a new save file with the desired nickname
            SaveDataTestImpl saveData = SaveDataTestImpl.NewSaveFile(nickName);

            for (int i = 0; i < saveCount; i++)
            {
                if (i != 0)
                {
                    Log($"Waiting {SaveData.ReSaveDelay} before continuing...");
                }

                //add a unique value into the save data
                saveData.Word = $"SAVE_{i}";

                //re-save the save data
                yield return(new WaitForSecondsRealtime(0.1f));

                saveData.Save(false);

                Log($"Saved {nickName} #{i}:\n{saveData}");

                AssertAll.Of(
                    //Assert that the timestamp in the filename matches the lastSaveTime
                    () => Assert.That(saveData, Has.Property(nameof(saveData.LastSaveTime_Exact)).Not.Null),
                    () => Assert.That(
                        saveData.LastSaveTime_Exact?.Ticks,
                        Is.EqualTo(SaveDataTestImpl.GetSaveDate(saveData.LatestSaveFilePath).Ticks),
                        $"Incorrect timestamp pulled from path {saveData.LatestSaveFilePath}"
                        ),
                    //load the save data and check the unique value
                    () => Assert.That(SaveDataTestImpl.Load(nickName).Word, Is.EqualTo(saveData.Word))
                    );
            }
        }
예제 #3
0
 public void LoadingInvalidContentByNicknameThrowsSaveDataException()
 {
     Assert.Throws <SaveDataException>(() => SaveDataTestImpl.Load(DummyNickName));
 }