Ejemplo n.º 1
0
 public void Setup()
 {
     _store.SafeAddArticle(_article);
     _store.SafeAddArticle(_otherArticle);
     _store.SafeAddArticle(_lockedArticle);
     _articleManager = new ArticleManager(_store);
 }
Ejemplo n.º 2
0
        public void Setup()
        {
            _articles = new List <Article>();
            _articles.AddRange(new Article[]
            {
                new Article()
                {
                    Title       = "Article One",
                    Slug        = "2019/01/article-one",
                    PublishDate = new DateTime(2019, 1, 10, 12, 34, 56),
                    Content     = "This is article one, published on January 10, 2019 at 12:34pm UTC"
                },

                new Article()
                {
                    Title       = "Article Three",
                    Slug        = "2019/07/article-three",
                    PublishDate = new DateTime(2019, 7, 6, 18, 34, 56),
                    Content     = "This is article three, published on July 6, 2019 at 6:34pm UTC"
                },

                new Article()
                {
                    Title       = "Article Two",
                    Slug        = "2019/01/article-two",
                    PublishDate = new DateTime(2019, 1, 10, 14, 57, 32),
                    Content     = "This is article two, published on January 10, 2019 at 2:57pm UTC"
                },

                new Article()
                {
                    Title       = "Older Article",
                    Slug        = "2018/07/older-article",
                    PublishDate = new DateTime(2018, 7, 30, 10, 2, 0),
                    Content     = "This is an older article from the previous year (2018)"
                }
            });

            _articleStore = new InMemoryArticleStore();
            foreach (var article in _articles)
            {
                _articleStore.SafeAddArticle(article);
            }

            WebSiteOptions options = new WebSiteOptions()
            {
                WebSiteTitle = SITE_NAME
            };

            var userManager = ConfigurationHelper
                              .CreateServiceProvider()
                              .GetService <Microsoft.AspNetCore.Identity.UserManager <ApplicationUser> >();

            _controller = new Controllers.homeController(_articleStore, options, userManager);
        }
Ejemplo n.º 3
0
        public void TestDetailNoDescription()
        {
            int    year  = 2019;
            int    month = 10;
            string slug  = "slug";
            string title = "Title for Test Detail";

            var article = new Article()
            {
                Title       = title,
                PublishDate = new DateTime(year, month, 1),
                Slug        = $"{year}/{month}/{slug}"
            };

            articleStore.SafeAddArticle(article);

            var result = controller.details(year.ToString(), month.ToString(), slug).GetAwaiter().GetResult() as ViewResult;

            Assert.AreSame(article, result.Model);
            Assert.AreEqual(title, result.ViewData[Constants.VIEWDATA_PAGETITLE]);
        }
        public void Setup()
        {
            _articles.Clear();
            _articles.AddRange(new Article[]
            {
                new Article()
                {
                    Title       = "Article One",
                    Slug        = "2019/01/article-one",
                    PublishDate = new DateTime(2019, 1, 10, 12, 34, 56),
                    Content     = "This is article one, published on January 10, 2019 at 12:34pm UTC"
                },

                new Article()
                {
                    Title       = "Article Three",
                    Slug        = "2019/07/article-three",
                    PublishDate = new DateTime(2019, 7, 6, 18, 34, 56),
                    Content     = "This is article three, published on January 10, 2019 at 6:34pm UTC"
                },

                new Article()
                {
                    Title       = "Article Two",
                    Slug        = "2019/01/article-two",
                    PublishDate = new DateTime(2019, 1, 10, 14, 57, 32),
                    Content     = "This is article two, published on January 10, 2019 at 2:57pm UTC"
                },

                new Article()
                {
                    Title       = "Older Article",
                    Slug        = "2018/07/older-article",
                    PublishDate = new DateTime(2018, 7, 30, 10, 2, 0),
                    Content     = "This is an older article from the previous year (2018)"
                },

                new Article()
                {
                    Title       = "Article Four",
                    Slug        = "2019/08/article-four",
                    PublishDate = new DateTime(2019, 8, 31, 10, 2, 0),
                    Content     = "This is article two, published on August 31, 2019 at 10:02am UTC"
                },
            });
            Store = new InMemoryArticleStore();
            foreach (var a in _articles)
            {
                Store.SafeAddArticle(a);
            }
        }