public void GetChildCategoriesByParentId_ReturnsOnlyAssociatedCategories() { IDbProxyContext context = Mock.It<IDbProxyContext>(); List<ItemCategory> categories = new List<ItemCategory> { _musicParent, _musicChild, _musicChild2, _musicGrandChild }; context.Set<ItemCategory>().Returns(categories.AsQueryable()); var itemCategoryRelationDAO = new ItemCategoryDAOImpl(context, Mock.It<IDbManager>(), Mock.It<ILogger>()); IEnumerable<ItemCategoryCount> categoryCounts = itemCategoryRelationDAO.GetChildCategoriesByParentId(Guid.Parse(Id)).ToList(); Assert.That(categoryCounts.Count(), Is.EqualTo(2)); Assert.That(categoryCounts.Count(c => c.Name == MusicVideoCategory), Is.EqualTo(1)); Assert.That(categoryCounts.Count(c => c.Name == MusicInstrumentCategory), Is.EqualTo(1)); }
public void GetTopLevelCategoriesWithChildren_ReturnsOnlyTopLevelCategoriesWithChildren() { IDbProxyContext context = Mock.It<IDbProxyContext>(); List<ItemCategory> categories = new List<ItemCategory> { _musicParent, _musicChild, _musicChild2, _musicGrandChild//, BuildItemCategory("Books") }; context.Set<ItemCategory>().Returns(categories.AsQueryable()); var itemCategoryRelationDAO = new ItemCategoryDAOImpl(context, dbManager, Mock.It<ILogger>()); List<ItemCategoryCount> itemCategories = itemCategoryRelationDAO.GetTopLevelCategoriesWithChildren().ToList(); Assert.That(itemCategories.Count, Is.EqualTo(1)); Assert.That(itemCategories[0].Name, Is.EqualTo(MusicCategory)); Assert.That(itemCategories[0].TotalCount, Is.EqualTo(2)); }
public void GetTopLevelCategoriesWithNoChildren_ReturnsOnlyTopLevelCategoriesWithNoChildren() { const string expectedItemName = "Books"; IDbProxyContext context = Mock.It<IDbProxyContext>(); List<ItemCategory> categories = new List<ItemCategory> { _musicParent, _musicChild, _musicChild2, _musicGrandChild, new ItemCategory(Guid.NewGuid(), expectedItemName) }; context.Set<ItemCategory>().Returns(categories.AsQueryable()); var itemCategoryRelationDAO = new ItemCategoryDAOImpl(context, dbManager, Mock.It<ILogger>()); List<ItemCategoryCount> itemCategories = itemCategoryRelationDAO.GetTopLevelCategoriesWithNoChildren().ToList(); Assert.That(itemCategories.Count, Is.EqualTo(2)); Assert.That(itemCategories[0].Name, Is.EqualTo(expectedItemName)); }
public void TestQuery() { ItemCategoryDAO dao = new ItemCategoryDAOImpl(new DbProxyContext(), Mock.It<IDbManager>(), Mock.It<ILogger>()); IEnumerable<ItemCategoryCount> categories = dao.GetChildCategoriesByParentId(Guid.Parse(Id)); Assert.True(categories.Any()); }