Exemple #1
0
        public async Task UpdateAsync()
        {
            dbContext.PropertyTypeModel.Add(new PropertyTypeModel {
                Id = 1, Name = "Free"
            });
            dbContext.PropertyTypeModel.Add(new PropertyTypeModel {
                Id = 2, Name = "Lease"
            });
            dbContext.SaveChanges();

            var repo     = new PropertyTypeRepository(dbContext);
            var toUpdate = dbContext.PropertyTypeModel.First(m => m.Id == 1);

            toUpdate.Name = "Freehold";
            var result = repo.UpdateAsync(toUpdate);

            Assert.IsNotNull(result);
            Assert.AreEqual(dbContext.PropertyTypeModel.First(m => m.Id == 1).Id, 1);
            Assert.AreEqual(dbContext.PropertyTypeModel.First(m => m.Id == 1).Name, "Freehold");
        }