示例#1
0
 public void Delete(Guid textId)
 {
     if (TextRepository.Exists(textId))
     {
         Text textToDelete = TextRepository.GetById(textId);
         IEnumerable <Text> textsInContent = TextRepository.GetByContent(textToDelete.ContentThatBelongs);
         foreach (Text textInContent in textsInContent)
         {
             if (textInContent.Position > textToDelete.Position)
             {
                 textInContent.Position--;
                 TextRepository.Update(textInContent);
             }
         }
         TextRepository.Delete(textId);
     }
     else
     {
         throw new MissingTextException("This text is not in the database");
     }
 }
示例#2
0
        public void testDelete()
        {
            // Arrange
            repo.Add(entity);
            repo.SaveChanges();
            int count = repo.All().Count();

            Guid id = repo.GetByName(n).Id;

            // Act
            repo.Delete(entity);
            repo.SaveChanges();
            // Assert

            Assert.Null(repo.GetByName(n));
            Assert.True(repo.All().Count() == count - 1);
            Assert.True(repo.GetById(id).IsDeleted);

            this.repo.HardDelete(entity);
            this.repo.SaveChanges();

            //TODO add all remaining methods
        }