public void CommitSaveData_UpdateTimeStampIsFalse_TimeStampAndCommitIdAreNotUpdated() { var random = new RandomGenerator(); RandomDataGenerator randomGeneratorFunc = buffer => random.GenerateRandom(buffer); var timeStampGetter = new TimeStampGetter(); var baseFs = new InMemoryFileSystem(); DirectorySaveDataFileSystem.CreateNew(out DirectorySaveDataFileSystem saveFs, baseFs, timeStampGetter, randomGeneratorFunc, true, true, true, null).ThrowIfFailure(); saveFs.CommitExtraData(true).ThrowIfFailure(); saveFs.ReadExtraData(out SaveDataExtraData extraData).ThrowIfFailure(); Assert.Equal(1u, extraData.TimeStamp); Assert.Equal(2, extraData.CommitId); saveFs.CommitExtraData(false).ThrowIfFailure(); saveFs.ReadExtraData(out extraData).ThrowIfFailure(); Assert.Equal(1u, extraData.TimeStamp); Assert.Equal(2, extraData.CommitId); saveFs.CommitExtraData(true).ThrowIfFailure(); saveFs.ReadExtraData(out extraData).ThrowIfFailure(); Assert.Equal(2u, extraData.TimeStamp); Assert.Equal(3, extraData.CommitId); saveFs.CommitExtraData(false).ThrowIfFailure(); saveFs.ReadExtraData(out extraData).ThrowIfFailure(); Assert.Equal(2u, extraData.TimeStamp); Assert.Equal(3, extraData.CommitId); }
public void CommitSaveData_MultipleCommits_CommitIdIsUpdatedSkippingInvalidIds() { var random = new RandomGenerator(); RandomDataGenerator randomGeneratorFunc = buffer => random.GenerateRandom(buffer); var timeStampGetter = new TimeStampGetter(); var baseFs = new InMemoryFileSystem(); DirectorySaveDataFileSystem.CreateNew(out DirectorySaveDataFileSystem saveFs, baseFs, timeStampGetter, randomGeneratorFunc, true, true, true, null).ThrowIfFailure(); saveFs.CommitExtraData(true).ThrowIfFailure(); saveFs.ReadExtraData(out SaveDataExtraData extraData).ThrowIfFailure(); Assert.Equal(2, extraData.CommitId); saveFs.CommitExtraData(true).ThrowIfFailure(); saveFs.ReadExtraData(out extraData).ThrowIfFailure(); Assert.Equal(3, extraData.CommitId); saveFs.CommitExtraData(true).ThrowIfFailure(); saveFs.ReadExtraData(out extraData).ThrowIfFailure(); Assert.Equal(6, extraData.CommitId); saveFs.CommitExtraData(true).ThrowIfFailure(); saveFs.ReadExtraData(out extraData).ThrowIfFailure(); Assert.Equal(2, extraData.CommitId); }