public void Animals_can_be_persisted_and_retrieved() { //Arrange var sutProvider = new DataProvider <Animal>(_config, Animal.ToDomainConverter); var columns = sutProvider.LoadAllColumns(); var sutPersister = new AnimalPersister(columns, _config); var animalRecord = TestData.Animals.Chihuahua; //Act ErrorMessage error; var persistResult = sutPersister.TryPersist(ref animalRecord, out error); //Assert Assert.IsTrue(persistResult); Assert.IsNull(error); //The new row id is assigned to ref of the object Assert.IsNotNull(animalRecord.AnimalId); Assert.IsInstanceOf <int>(animalRecord.AnimalId); var readResult = sutProvider.LoadAll().First(); Assert.AreEqual(TestData.Animals.Chihuahua, readResult); Assert.AreEqual(animalRecord.AnimalId, readResult.AnimalId); }
private bool PersistAnimal(out ErrorMessage error, ref Animal persistedAnimal) { var provider = new DataProvider <Animal>(_config, Animal.ToDomainConverter); var columns = provider.LoadAllColumns(); var persister = new AnimalPersister(columns, _config); return(persister.TryPersist(ref persistedAnimal, out error)); }