public void LoadYamlTest() { YamlRepository repo = GetYamlRepo(nameof(LoadYamlTest)); // save some stuff to daorepo string details = 10.RandomLetters(); string testName = 8.RandomLetters(); Parent parent = new Parent { Details = details, Name = testName }; parent = repo.DaoRepository.Save(parent); FileInfo yamlFile = repo.GetYamlFile(typeof(Parent), parent.Name); string yamlFilePath = repo.YamlDataDirectory.GetYamlFilePath(typeof(Parent), parent.Name); Expect.IsFalse(File.Exists(yamlFilePath), $"file existed but shouldn't have: {yamlFilePath}"); Expect.IsNull(yamlFile); FileInfo loadNamesFile = repo.GetLoadNamesFile(typeof(Parent)); // write names to sync file repo.AddNameToLoad <Parent>(parent.Name); // Call LoadYaml repo.WriteYaml(); // expect yaml files to exist yamlFile = repo.GetYamlFile(typeof(Parent), parent.Name); Expect.IsNotNull(yamlFile); Parent fromYaml = repo.ReadYaml <Parent>(parent.Name); Expect.AreEqual(fromYaml.Cuid, parent.Cuid); Expect.AreEqual(fromYaml.Name, parent.Name); Expect.AreEqual(fromYaml.Uuid, parent.Uuid); }
public void CanAddNameToLoad() { YamlRepository repo = GetYamlRepo(nameof(CanAddNameToLoad)); FileInfo loadNamesFile = repo.GetLoadNamesFile(typeof(Parent)); if (File.Exists(loadNamesFile.FullName)) { File.Delete(loadNamesFile.FullName); } Expect.IsFalse(File.Exists(loadNamesFile.FullName)); HashSet <string> names = repo.AddNameToLoad <Parent>("monkey"); Expect.IsTrue(File.Exists(loadNamesFile.FullName)); names = repo.AddNameToLoad <Parent>("monkey"); names = repo.AddNameToLoad <Parent>("banana"); Expect.AreEqual(2, names.Count); List <string> fromFile = File.ReadAllLines(loadNamesFile.FullName).ToList(); Expect.AreEqual(2, fromFile.Count); Expect.IsTrue(fromFile.Contains("monkey")); Expect.IsTrue(fromFile.Contains("banana")); }