Esempio n. 1
0
        public void TestPostID()
        {
            WPContentViewModel contentViewModel = new WPContentViewModel();
            WPContentProvider  _wpContentSvc    = new WPContentProvider();
            var id = "INSERT YOUR POST ID TO TEST HERE";
            int idNumberValue;


            contentViewModel.PostModel =

                //detect whether the id is an int or a string
                Int32.TryParse(id, out idNumberValue)
                ? (WPPostPageModel)

                //if the id is an int, apply the "include" filter
                _wpContentSvc.GetWPContent(WPEnums.ContentTypes.POST,
                                           new Dictionary <WPEnums.Filters, string>()
            {
                { WPEnums.Filters.include, WPEnums.Filters.include.Apply(idNumberValue.ToString()) }
            })
                : (WPPostPageModel)

                //if the id is a string, apply the "slug" filter
                _wpContentSvc.GetWPContent(WPEnums.ContentTypes.POST,
                                           new Dictionary <WPEnums.Filters, string>()
            {
                { WPEnums.Filters.slug, WPEnums.Filters.slug.Apply(id) }
            });

            Assert.IsTrue(contentViewModel.PostModel != null && contentViewModel.PostModel.ContainsContent() && !contentViewModel.PostModel.GetSafeContent().Contains("404"));
        }
Esempio n. 2
0
        public void TestCategorySlug()
        {
            WPContentViewModel contentViewModel = new WPContentViewModel();
            WPContentProvider  _wpContentSvc    = new WPContentProvider();
            var id = "INSERT YOUR SLUG TO TEST HERE";
            int idNumberValue;


            contentViewModel.PostCategories =

                //detect whether the id is an int or a string
                //both implementation use the "_embed" filter, which is required for featuredMedia, wpterms, authors
                Int32.TryParse(id, out idNumberValue)
                               ? (WPPostCategories)

                //if the id is an int, apply the "categories" filter
                _wpContentSvc.GetWPContent(WPEnums.ContentTypes.POSTCATEGORY,
                                           new Dictionary <WPEnums.Filters, string>()
            {
                { WPEnums.Filters.categories, WPEnums.Filters.categories.Apply(idNumberValue.ToString()) },
                { WPEnums.Filters._embed, WPEnums.Filters._embed.Apply("_embed") }
            })
                               : (WPPostCategories)

                //if the id is a string, apply the "filter" params
                _wpContentSvc.GetWPContent(WPEnums.ContentTypes.POSTCATEGORY,
                                           new Dictionary <WPEnums.Filters, string>()
            {
                { WPEnums.Filters.filter, WPEnums.Filters.filter.Apply(id, "category_name") },
                { WPEnums.Filters._embed, WPEnums.Filters._embed.Apply("_embed") }
            });

            Assert.IsTrue(contentViewModel.PostCategories != null && contentViewModel.PostCategories.CategoryCollection != null && contentViewModel.PostCategories.CategoryCollection.Any());
        }