Пример #1
0
 public void Setup()
 {
     articleStore = new InMemoryArticleStore();
     controller   = new Controllers.blogController(articleStore, new DefaultMarkdownHtmlRenderer(), new WebSiteOptions());
     controller.ControllerContext.HttpContext = new Microsoft.AspNetCore.Http.DefaultHttpContext
     {
         // No claims; i.e., not logged in
         User = new System.Security.Claims.ClaimsPrincipal()
     };
 }
Пример #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);
        }
        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);
            }
        }