Ejemplo n.º 1
0
        public void TermController_RemoveTermsFromContent_Throws_On_Null_ContentItem()
        {
            //Arrange
            var mockDataService = new Mock <IDataService>();
            var termController  = new TermController(mockDataService.Object);

            //Act, Arrange
            Assert.Throws <ArgumentNullException>(() => termController.RemoveTermsFromContent(null));
        }
Ejemplo n.º 2
0
        public void TermController_RemoveTermsFromContent_Should_Call_DataService_If_Valid_Params()
        {
            //Arrange
            var mockDataService = new Mock <IDataService>();
            var termController  = new TermController(mockDataService.Object);

            ContentItem content = ContentTestHelper.CreateValidContentItem();

            // Act
            termController.RemoveTermsFromContent(content);

            // Assert
            mockDataService.Verify(ds => ds.RemoveTermsFromContent(content));
        }
Ejemplo n.º 3
0
        public void UpdateTabFromNewsEntry(TabInfo activeTab, INewsEntry newsEntry)
        {
            activeTab.TabName     = HtmlUtils.Shorten(newsEntry.Title, 200, "...");
            activeTab.Title       = activeTab.TabName;
            activeTab.Description = HtmlUtils.Shorten(
                HtmlUtils.StripTags(
                    HttpUtility.HtmlDecode(newsEntry.Description), true).Trim(), 500, "...");

            activeTab.StartDate = newsEntry.StartDate.GetValueOrDefault();
            activeTab.EndDate   = (newsEntry.EndDate != null) ? newsEntry.EndDate.Value : DateTime.MaxValue;

            var tabCtrl = new TabController();

            tabCtrl.UpdateTab(activeTab);

            var termCtrl = new TermController();

            termCtrl.RemoveTermsFromContent(activeTab);
            foreach (var term in newsEntry.ContentItem.Terms)
            {
                termCtrl.AddTermToContent(term, activeTab);
            }
        }
Ejemplo n.º 4
0
        public void UpdateNewsEntry(NewsEntryInfo newsEntry, List <Term> terms, int moduleId, int tabId)
        {
            // TODO: Update value of ContentKey
            // update content item
            newsEntry.ContentItem.ContentTitle = newsEntry.Title;
            newsEntry.ContentItem.Content      = newsEntry.Title;
            newsEntry.ContentItem.ModuleID     = newsEntry.AgentModuleId ?? moduleId;
            newsEntry.ContentItem.TabID        = tabId;
            NewsDataProvider.Instance.ContentController.UpdateContentItem(newsEntry.ContentItem);

            NewsDataProvider.Instance.Update <NewsEntryInfo> (newsEntry);

            // update content item terms
            var termController = new TermController();

            termController.RemoveTermsFromContent(newsEntry.ContentItem);
            foreach (var term in terms)
            {
                termController.AddTermToContent(term, newsEntry.ContentItem);
            }

            CacheHelper.RemoveCacheByPrefix(NewsCacheKeyPrefix);
        }