public void add_test() { var id = 0; using (var uow = new Core.DapperUnit(connectionString)) { // specific implementation uow.Repositories.Add(typeof(Pirate), new PirateRepository(uow)); // generic implementation uow.Repositories.Add(typeof(Country), new Repository <Country>(uow)); var country = uow.Repository <Country>().Find(1); id = uow.Repository <Pirate>().Add(new Pirate { Name = "Stanny", CountryId = country.Id, Country = country }); uow.Commit(); } using (var uow = new Core.DapperUnit(connectionString)) { uow.Repositories.Add(typeof(Pirate), new PirateRepository(uow)); var pirate = uow.Repository <Pirate>().Find(id); Assert.NotNull(pirate); Assert.AreEqual(id, pirate.Id); } }
public void find_by_id() { using (var uow = new Core.DapperUnit(connectionString)) { // specific implementation uow.Repositories.Add(typeof(Pirate), new PirateRepository(uow)); var pirate = uow.Repository <Pirate>().Find(1); } }