예제 #1
0
        public void WhenAnArticleIsRemovedThenItShouldNotBePresent()
        {
            var articleRepo = new InMemoryArticleRepository();

            articleRepo.ClearArticles();
            Article newArticle = Article.CreateNewArticle("Title", "Body", DateTime.Now, "Khurram");

            articleRepo.AddArticle(newArticle);

            var target = articleRepo.GetAll().ToList();


            Assert.AreEqual(1, target.Count);
            articleRepo.RemoveArticle(newArticle.Id);

            var collection = articleRepo.GetAll().ToList();

            Assert.AreEqual(0, collection.Count);
        }
예제 #2
0
        public void WhenAddANewArticleThenItShouldBeSaved()
        {
            var     articleRepo = new InMemoryArticleRepository();
            Article newArticle  = Article.CreateNewArticle("Title", "Body", DateTime.Now, "Khurram");

            articleRepo.AddArticle(newArticle);

            var target = articleRepo.GetAll().ToList()[0];

            Assert.AreEqual(newArticle.Id, target.Id);
            Assert.AreEqual(newArticle.Title, target.Title);
            Assert.AreEqual(newArticle.PublishDate, target.PublishDate);
            Assert.AreEqual(newArticle.Publisher, target.Publisher);
        }
예제 #3
0
        public void WhenArticleInformationIsAlteredThenItShouldBeUpdated()
        {
            var articleRepo = new InMemoryArticleRepository();

            articleRepo.ClearArticles();
            Article newArticle = Article.CreateNewArticle("Title", "Body", DateTime.Now, "Khurram");

            articleRepo.AddArticle(newArticle);

            articleRepo.UpdateArticle(newArticle.Id, "Title Changed", "Body Changed", newArticle.PublishDate, newArticle.Publisher);
            var target = articleRepo.GetAll().ToList()[0];

            Assert.AreEqual("Title Changed", target.Title);
            Assert.AreEqual("Body Changed", target.Body);
            Assert.AreEqual(true, newArticle.PublishDate.Equals(target.PublishDate));
            Assert.AreEqual(newArticle.Publisher, target.Publisher);
        }