public bool UpdateExisitingCache(Cache c) { ValidateCache(c); // in addition check if cache owner is authenticated user if (c.OwnerId == authenticatedUser.Id) { return(cacheDao.Update(c)); } throw new Exception("Error: You are not the cache owner and therefor not permitted to change any details."); }
public void UpdateTest() { const int id = 112; Cache actual = target.GetById(id); String originalName = actual.Name; String expectedName = actual.Name + id; var creationDate = new DateTime(2008, 07, 19); actual.Name = expectedName; Assert.IsTrue(target.Update(actual)); actual = target.GetById(id); Assert.AreEqual(expectedName, actual.Name); Assert.AreEqual(creationDate, actual.CreationDate); actual.Name = originalName; Assert.IsTrue(target.Update(actual)); actual = target.GetById(id); Assert.AreEqual(originalName, actual.Name); }