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 Repository_should_save_and_load_model() { var repository = new YamlRepository(); var expected = _fixture.Create <SystemModel>(); repository.Save(expected, _directory); var actual = repository.Load(_directory); actual.AssertDeepEqualsTo(expected); }
public void YamlRepositoryCreateRetrieveTest() { Parent parent = new Parent { Details = "Some details" }; House house = new House { HouseDetails = "house details" }; parent.Houses = new List <House>(); parent.Houses.Add(house); YamlRepository repo = GetYamlRepo(nameof(YamlRepositoryCreateRetrieveTest)); parent = repo.Save(parent); Parent retrieved = repo.Retrieve <Parent>(parent.Id); Expect.IsNotNull(retrieved); Expect.IsNotNull(retrieved.Houses); Expect.AreEqual(1, retrieved.Houses.Count); }
[Test] public void Repository_should_load_roles_with_no_mapped_machines() { var model = new SystemModel(new[] { new Role("api", new [] { "dev1", "dev2" }), new Role("csapi", new string[] {}), new Role("service", null) }, new[] { new Tenant("a", new [] { "dev1" }), }, new[] { new TenantTag("a", new [] { "dev1" }) }); var repository = new YamlRepository(); repository.Save(model, _directory); var actual = repository.Load(_directory); actual.AssertDeepEqualsTo(model); }