コード例 #1
0
        public void WhenAskForOnlyThePublishedCategories_ShouldReturnOnlyThePublishedCategoriesCount()
        {
            // Arange
            var expectedCategoriesCount = _existigCategories.Count(x => x.Published && !x.Deleted);

            // Act
            var categoriesCount = _categoryApiService.GetCategoriesCount(publishedStatus: true);

            // Assert
            Assert.AreEqual(expectedCategoriesCount, categoriesCount);
        }
コード例 #2
0
        public void WhenCalledWithUpdatedAtMinParameter_GivenSomeCategoriesUpdatedAfterThatDate_ShouldReturnTheirCount()
        {
            // Arange
            DateTime updatedAtMinDate        = _baseDate.AddMonths(5);
            var      expectedCollection      = _existigCategories.Where(x => x.UpdatedOnUtc > updatedAtMinDate && !x.Deleted);
            var      expectedCategoriesCount = expectedCollection.Count();

            // Act
            var categoriesCount = _categoryApiService.GetCategoriesCount(updatedAtMin: updatedAtMinDate);

            // Assert
            Assert.AreEqual(expectedCategoriesCount, categoriesCount);
        }
コード例 #3
0
        public void WhenCalledWithValidProductId_ShouldReturnOnlyTheCountOfTheCategoriesMappedToThisProduct()
        {
            // Arange
            int productId = 3;
            var expectedCollectionCount = (from cat in _existigCategories
                                           join mapping in _existingCategoryMappings on cat.Id equals mapping.CategoryId
                                           where mapping.ProductId == productId
                                           orderby cat.Id
                                           select cat).Count();

            // Act
            var categoriesCount = _categoryApiService.GetCategoriesCount(productId: productId);

            // Assert
            Assert.AreEqual(expectedCollectionCount, categoriesCount);
        }
コード例 #4
0
        public IActionResult GetCategoriesCount(CategoriesCountParametersModel parameters)
        {
            var allCategoriesCount = _categoryApiService.GetCategoriesCount(parameters.CreatedAtMin, parameters.CreatedAtMax,
                                                                            parameters.UpdatedAtMin, parameters.UpdatedAtMax,
                                                                            parameters.PublishedStatus, parameters.ProductId);

            var categoriesCountRootObject = new CategoriesCountRootObject()
            {
                Count = allCategoriesCount
            };

            return(Ok(categoriesCountRootObject));
        }