static void Main(string[] args) { ICityRepository cityRepo = new InMemoryCityRepository(); IPersonRepository personRepo = new InMemoryPersonRepository(cityRepo); foreach (var p in personRepo.Context) { Console.WriteLine(p); } var toulon = cityRepo.Single("Toulon"); toulon.Name = "New York"; cityRepo.Update(toulon); cityRepo.SaveChanges(); foreach (var p in personRepo.Context) { Console.WriteLine(p); } }
public void DiTest() { ICityRepository cityRepo = new InMemoryCityRepository(); var personRepo = PersonRepoFactory.Create(cityRepo); Assert.True( personRepo .Single("DAVIS Miles")?.BornIn?.Name == "Toulon"); var cityId = personRepo .Single("DAVIS Miles")?.BornIn?.Id; var toulon = cityRepo.Single("Toulon"); toulon.Name = "New York"; cityRepo.Update(toulon); cityRepo.SaveChanges(); Assert.True( personRepo .Single("DAVIS Miles")?.BornIn?.Name == "New York"); var updatedCityId = personRepo .Single("DAVIS Miles")?.BornIn?.Id; Assert.True(cityId == updatedCityId); }