Пример #1
0
        static List <Term> GetTerms(AnnouncementInfo announcement, ModuleInfo module, TabController tabController, TermController termController)
        {
            var terms = new List <Term> ();

            // try get terms from target tab
            if (Globals.GetURLType(announcement.Url) == TabType.Tab)
            {
                var tab = tabController.GetTab(int.Parse(announcement.Url), module.PortalID);
                if (tab != null)
                {
                    terms = termController.GetTermsByContent(tab.ContentItemId).ToList();
                }
            }

            // try get terms from module tab
            if (terms == null || terms.Count == 0)
            {
                var tab = tabController.GetTab(module.TabID, module.PortalID);
                if (tab != null)
                {
                    terms = termController.GetTermsByContent(tab.ContentItemId).ToList();
                }
            }

            return(terms);
        }
Пример #2
0
        public void TermController_GetTermsByContent_Throws_On_Invalid_ContentItemId()
        {
            //Arrange
            var mockDataService = new Mock <IDataService>();
            var termController  = new TermController(mockDataService.Object);

            //Act, Arrange
            Assert.Throws <ArgumentOutOfRangeException>(() => termController.GetTermsByContent(Null.NullInteger));
        }
Пример #3
0
        public void TermController_GetTermsByContent_Calls_DataService()
        {
            //Arrange
            var mockDataService = new Mock <IDataService>();

            mockDataService.Setup(ds => ds.GetTermsByContent(Constants.TERM_ValidContent1)).Returns(MockHelper.CreateValidTermsReader(Constants.TERM_ValidCountForContent1,
                                                                                                                                      v => Constants.TERM_ValidVocabularyId,
                                                                                                                                      c => Constants.TERM_ValidContent1));
            var termController = new TermController(mockDataService.Object);

            //Act
            IQueryable <Term> terms = termController.GetTermsByContent(Constants.TERM_ValidContent1);

            //Assert
            mockDataService.Verify(ds => ds.GetTermsByContent(Constants.TERM_ValidContent1));
        }
Пример #4
0
        public void TermController_GetTermsByContent_Returns_Terms_On_Valid_ContentItemId()
        {
            //Arrange
            var mockDataService = new Mock <IDataService>();

            mockDataService.Setup(ds => ds.GetTermsByContent(Constants.TERM_ValidContent1)).Returns(MockHelper.CreateValidTermsReader(Constants.TERM_ValidCountForContent1,
                                                                                                                                      v => Constants.TERM_ValidVocabularyId,
                                                                                                                                      c => Constants.TERM_ValidContent1));

            var termController = new TermController(mockDataService.Object);

            //Act
            var terms = termController.GetTermsByContent(Constants.TERM_ValidContent1).ToList();

            //Assert
            Assert.AreEqual(Constants.TERM_ValidCountForContent1, terms.Count);

            for (int i = 0; i < Constants.TERM_ValidCountForContent1; i++)
            {
                Assert.AreEqual(i + Constants.TERM_ValidTermId, terms[i].TermId);
                Assert.AreEqual(ContentTestHelper.GetTermName(i + Constants.TERM_ValidTermId), terms[i].Name);
            }
        }