public void testUpdate() { // Arrange int count = repo.All().Count(); repo.Add(entity); this.repo.SaveChanges(); Assert.Null(repo.GetByName(n + "alala")); Assert.AreEqual(count + 1, repo.All().Count()); entity.Name += "alala"; // Act repo.Update(entity); repo.SaveChanges(); // Assert Assert.NotNull(repo.GetByName(n + "alala")); this.repo.HardDelete(entity); this.repo.SaveChanges(); }
public Text AddToFooter(Guid footerId, Text text) { if (FooterRepository.Exists(footerId)) { Footer footer = FooterRepository.GetById(footerId); footer.StyleClass = null; Footer footerForText = footer; Content contentOfFooter = footerForText.Content; IEnumerable <Text> footerTexts = TextRepository.GetByContent(contentOfFooter); if (footerTexts.Count() == 0) { text.Id = Guid.NewGuid(); text.Position = 0; text.ContentThatBelongs = contentOfFooter; TextRepository.Add(text); return(text); } else { throw new ExistingTextException("There is an existing text in the selected footer."); } } else { throw new MissingFooterException("This footer does not exist in the database"); } }
public Text AddToHeader(Guid headerId, Text text) { if (HeaderRepository.Exists(headerId)) { Header header = HeaderRepository.GetById(headerId); header.StyleClass = null; Header headerForText = header; Content contentOfHeader = headerForText.Content; IEnumerable <Text> headerTexts = TextRepository.GetByContent(contentOfHeader); if (headerTexts.Count() == 0) { text.Id = Guid.NewGuid(); text.Position = 0; text.ContentThatBelongs = contentOfHeader; TextRepository.Add(text); return(text); } else { throw new ExistingTextException("There is an existing text in the selected header."); } } else { throw new MissingHeaderException("This header does not exist in the database"); } }
public Text AddToParagraph(Guid paragraphId, Text text) { if (ParagraphRepository.Exists(paragraphId)) { Paragraph paragraph = ParagraphRepository.GetById(paragraphId); paragraph.StyleClass = null; Paragraph paragraphForText = paragraph; Content contentOfParagraph = paragraphForText.Content; IEnumerable <Text> paragraphTexts = TextRepository.GetByContent(contentOfParagraph); text.Id = Guid.NewGuid(); text.Position = paragraphTexts.Count(); text.ContentThatBelongs = contentOfParagraph; TextRepository.Add(text); return(text); } else { throw new MissingParagraphException("This paragraph does not exist in the database"); } }