示例#1
0
        public void ContentController_GetUnIndexedContentItems_Returns_EmptyList_If_No_UnIndexed_Items()
        {
            // Arrange
            Mock <IDataService> mockDataService = new Mock <IDataService>();

            mockDataService.Setup(ds => ds.GetUnIndexedContentItems()).Returns(MockHelper.CreateEmptyContentItemReader());

            ContentController controller = new ContentController(mockDataService.Object);

            // Act
            IQueryable <ContentItem> contentItems = controller.GetUnIndexedContentItems();

            // Assert
            Assert.AreEqual(0, contentItems.Count());
        }
示例#2
0
        public void ContentController_GetContentItemsByTerm_Returns_Empty_List_If_Term_Not_Used()
        {
            // Arrange
            Mock <IDataService> mockDataService = new Mock <IDataService>();

            mockDataService.Setup(ds => ds.GetContentItemsByTerm(Constants.TERM_UnusedName)).Returns(MockHelper.CreateEmptyContentItemReader());
            ContentController controller = new ContentController(mockDataService.Object);

            // Act
            IQueryable <ContentItem> contentItems = controller.GetContentItemsByTerm(Constants.TERM_UnusedName);

            // Assert
            Assert.AreEqual(0, contentItems.Count());
        }
示例#3
0
        public void ContentController_GetContentItemsByContentType_Invalid_Id_Returns_No_Elements()
        {
            var mock = new Mock <IDataService>();

            mock.Setup(ds => ds.GetContentItemsByContentType(It.IsAny <int>())).Returns(MockHelper.CreateEmptyContentItemReader());

            var controller = new ContentController(mock.Object);

            var items = controller.GetContentItemsByContentType(-1).ToArray();

            Assert.IsEmpty(items);
        }
示例#4
0
        public void ContentController_GetContentItem_Returns_Null_On_InValid_ContentItemId()
        {
            // Arrange
            Mock <IDataService> mockDataService = new Mock <IDataService>();

            mockDataService.Setup(ds => ds.GetContentItem(Constants.CONTENT_InValidContentItemId)).Returns(MockHelper.CreateEmptyContentItemReader());
            ContentController controller = new ContentController(mockDataService.Object);

            // Act
            ContentItem content = controller.GetContentItem(Constants.CONTENT_InValidContentItemId);

            // Assert
            Assert.IsNull(content);
        }