public void YamlSyncToDbTest() { string details = 10.RandomLetters(); string updatedDetails = 5.RandomLetters(); string testName = 8.RandomLetters(); Parent parent = new Parent { Details = details, Name = testName }; YamlRepository repo = GetYamlRepo(nameof(YamlSyncToDbTest)); parent = repo.Save(parent); Parent loaded = repo.LoadYaml <Parent>(testName).ToList().FirstOrDefault(); Expect.IsNotNull(loaded); loaded.Details = updatedDetails; repo.YamlDataDirectory.Save <Parent>(loaded); FileInfo file = repo.YamlDataDirectory.GetYamlFile(typeof(Parent), testName); YamlDataFile data = new YamlDataFile(typeof(Parent), file); Parent fromFile = data.As <Parent>(); Expect.AreEqual(testName, fromFile.Name); Expect.AreEqual(updatedDetails, fromFile.Details); Parent fromDb = repo.DaoRepository.Retrieve <Parent>(fromFile.Id); Expect.AreEqual(details, fromDb.Details); repo.Synchronize(); fromDb = repo.DaoRepository.Retrieve <Parent>(fromFile.Id); Expect.AreEqual(testName, fromDb.Name); Expect.AreEqual(updatedDetails, fromDb.Details); }
public void YamlSyncFromDbTest() { YamlRepository repo = GetYamlRepo(nameof(LoadYamlTest)); string details = 10.RandomLetters(); string updatedDetails = 15.RandomLetters(); string testName = 8.RandomLetters(); Parent parent = new Parent { Details = details, Name = testName }; parent = repo.DaoRepository.Save(parent); repo.AddNameToLoad <Parent>(parent.Name); repo.WriteYaml(); Parent fromFile = repo.ReadYaml <Parent>(parent.Name); Expect.AreEqual(fromFile.Details, parent.Details); parent.Details = updatedDetails; parent = repo.DaoRepository.Save(parent); repo.Synchronize(); fromFile = repo.ReadYaml <Parent>(parent.Name); Expect.AreEqual(fromFile.Details, updatedDetails); }