コード例 #1
0
        public void TermController_GetTermsByContent_Returns_Terms_On_Valid_ContentItemId()
        {
            //Arrange
            Mock<IDataService> 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));

            TermController termController = new TermController(mockDataService.Object);

            //Act
            List<Term> 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);
            }
        }
コード例 #2
0
        public void TermController_GetTermsByContent_Throws_On_Invalid_ContentItemId()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            TermController termController = new TermController(mockDataService.Object);

            //Act, Arrange
            Assert.Throws<ArgumentOutOfRangeException>(() => termController.GetTermsByContent(Null.NullInteger));
        }
コード例 #3
0
        public void TermController_GetTermsByContent_Calls_DataService()
        {
            //Arrange
            Mock<IDataService> 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));
            TermController termController = new TermController(mockDataService.Object);

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

            //Assert
            mockDataService.Verify(ds => ds.GetTermsByContent(Constants.TERM_ValidContent1));
        }