Пример #1
0
        private bool IsValidFooter(Guid footerId)
        {
            if (!FooterRepository.Exists(footerId))
            {
                throw new MissingFooterException("The footer does not exist.");
            }

            return(true);
        }
        public void TestFooterExistsFromDatabase()
        {
            User user = new User
            {
                UserName      = "******",
                Password      = "******",
                Name          = "name",
                LastName      = "lastname",
                Email         = Guid.NewGuid().ToString(),
                Administrator = true
            };

            UserRepository.Add(user);

            Document document = new Document
            {
                Id               = Guid.NewGuid(),
                Title            = "title1",
                Creator          = user,
                CreationDate     = DateTime.Now,
                LastModification = DateTime.Now,
                StyleClass       = null
            };

            DocumentRepository.Add(document);

            Content content = new Content
            {
                Id = Guid.NewGuid(),
            };

            ContentRepository.Add(content);

            Footer footer = new Footer
            {
                Id                  = Guid.NewGuid(),
                Content             = content,
                DocumentThatBelongs = document,
                StyleClass          = null
            };

            FooterRepository.Add(footer);

            bool exists = FooterRepository.Exists(footer.Id);

            DocumentRepository.Delete(document.Id);
            UserRepository.Delete(user.Email);
            ContentRepository.Delete(content);

            Assert.IsTrue(exists);
        }
        public void TestDocumentDeleteWithOneHeaderOneFooterOneParagraphFromDatabase()
        {
            User user4 = new User
            {
                UserName      = "******",
                Password      = "******",
                Name          = "name4",
                LastName      = "lastname3",
                Email         = "email3",
                Administrator = true
            };

            UserRepository.Add(user4);

            Document document = new Document
            {
                Id               = Guid.NewGuid(),
                Title            = "title",
                Creator          = user4,
                CreationDate     = DateTime.Now,
                LastModification = DateTime.Now,
                StyleClass       = null
            };

            DocumentRepository.Add(document);

            Header header = new Header
            {
                Id                  = Guid.NewGuid(),
                Content             = null,
                DocumentThatBelongs = document,
                StyleClass          = null
            };

            HeaderRepository.Add(header);

            Footer footer = new Footer
            {
                Id                  = Guid.NewGuid(),
                Content             = null,
                DocumentThatBelongs = document,
                StyleClass          = null
            };

            FooterRepository.Add(footer);

            Paragraph paragraph1 = new Paragraph
            {
                Id                  = Guid.NewGuid(),
                Content             = null,
                DocumentThatBelongs = document,
                StyleClass          = null,
                Position            = 0
            };

            ParagraphRepository.Add(paragraph1);

            Paragraph paragraph2 = new Paragraph
            {
                Id                  = Guid.NewGuid(),
                Content             = null,
                DocumentThatBelongs = document,
                StyleClass          = null,
                Position            = 1
            };

            ParagraphRepository.Add(paragraph2);

            DocumentRepository.Delete(document.Id);
            UserRepository.Delete(user4.Email);

            bool headerExistsAfterDelete     = HeaderRepository.Exists(header.Id);
            bool paragraph1ExistsAfterDelete = ParagraphRepository.Exists(paragraph1.Id);
            bool paragraph2ExistsAfterDelete = ParagraphRepository.Exists(paragraph2.Id);
            bool footerExistsAfterDelete     = FooterRepository.Exists(footer.Id);

            Assert.IsFalse(headerExistsAfterDelete);
            Assert.IsFalse(paragraph1ExistsAfterDelete);
            Assert.IsFalse(paragraph2ExistsAfterDelete);
            Assert.IsFalse(footerExistsAfterDelete);
        }