public void CustomRepo_AddOrUpdate_Update_Entry_Is_Updated() { TestPerson findByUpdated; using (IPersonRepository personRepository = new PersonRepository(new TestDatabaseContext())) { personRepository.AddOrUpdate(new TestPerson { Age = 28, Name = "Fabian" }); personRepository.Save(); TestPerson findBy = personRepository.GetSingle(x => x.Name == "Fabian"); findBy.Name = "Claudio"; personRepository.AddOrUpdate(findBy); personRepository.Save(); findByUpdated = personRepository.GetSingle(x => x.Name == "Claudio"); } Assert.IsNotNull(findByUpdated); Assert.IsTrue(findByUpdated.Name == "Claudio"); }
public void CustomRepo_AddOrUpdate_Add_Entry_Exists() { List<TestPerson> testPersons; using (IPersonRepository personRepository = new PersonRepository(new TestDatabaseContext())) { personRepository.AddOrUpdate(new TestPerson { Age = 28, Name = "Fabian" }); personRepository.Save(); testPersons = personRepository.GetAll().ToList(); } Assert.IsTrue(testPersons.Count == 1); }
public void CustomRepo_AddOrUpdate_Add_Entry_Exists() { List <TestPerson> testPersons; using (IPersonRepository personRepository = new PersonRepository(new TestDatabaseContext())) { personRepository.AddOrUpdate(new TestPerson { Age = 28, Name = "Fabian" }); personRepository.Save(); testPersons = personRepository.GetAll().ToList(); } Assert.IsTrue(testPersons.Count == 1); }