示例#1
0
        public void GetArticleResult_WithoutArticle_ShouldReturnPageWithoutArticle()
        {
            var repository = RepositoryTestHelper.GetMockRepository();

            var articleResult = repository.GetArticleResult(TestArticleId);

            Assert.IsFalse(articleResult.HasArticle);
        }
示例#2
0
        public void GetArticleResult_ArticleWithoutArticleRevision_ShouldReturnPageWithNullRevision()
        {
            var article = new Article(TestArticleId);

            var repository = RepositoryTestHelper.GetMockRepository(article);

            var articleResult = repository.GetArticleResult(TestArticleId);

            Assert.IsNull(articleResult.ArticleRevision);
        }
示例#3
0
        public void GetArticleResult_WithArticle_ShouldReturnArticleView()
        {
            var article         = new Article(TestArticleId);
            var articleRevision = new ArticleRevision(article.Id, string.Empty);

            var repository    = RepositoryTestHelper.GetMockRepository(article, articleRevision);
            var articleResult = repository.GetArticleResult(TestArticleId);

            Assert.IsNotNull(articleResult);
        }
示例#4
0
        public void GetArticleResult_WithArticleWithRedirectToArticle_ShouldReturnPageWithRedirect()
        {
            var articleRedirect = new ArticleRedirect(TestArticleId, TestRedirectArticleId);

            var repository = RepositoryTestHelper.GetMockRepository(articleRedirect: articleRedirect);

            var articleResult = repository.GetArticleResult(TestArticleId);

            Assert.IsTrue(articleResult.HasRedirect);
            Assert.AreEqual(TestArticleId.Slug, articleResult.ArticleRedirect.OriginalArticleSlug);
            Assert.AreEqual(TestRedirectArticleId.Slug, articleResult.ArticleRedirectId.Slug);
        }
示例#5
0
        public void GetArticleResult_WithSlugContainingSpace_ShouldThrowArticleIdNotEnsuredException()
        {
            var repository = RepositoryTestHelper.GetMockRepository();

            string urlContainingSpace = "URL WITH SPACE";

            string exceptionEnsuredSlug  = null;
            string exceptionOriginalSlug = null;

            try
            {
                repository.GetArticleResult(urlContainingSpace);
            }
            catch (ArticleIdNotEnsuredException ex)
            {
                exceptionEnsuredSlug  = ex.EnsuredSlug;
                exceptionOriginalSlug = ex.OriginalSlug;
            }

            var expectedEnsuredId = new ArticleId(urlContainingSpace);

            Assert.AreEqual(expectedEnsuredId.Slug, exceptionEnsuredSlug);
            Assert.AreEqual(urlContainingSpace, exceptionOriginalSlug);
        }