Exemple #1
0
        public void GetCategoryFaker_AmountBeyondMaxCategory_ShouldBeFallBackToMaxCategoryAmount()
        {
            var categories = CategoryFaker.GetCategoryList(12);

            _output.WriteLine(JsonConvert.SerializeObject(categories, Formatting.Indented));

            Assert.Equal(10, categories.Count);
        }
Exemple #2
0
        public void GetCategoryFaker_AmountLessThanMaxCategoryAmount_ShouldKeepItsAmount()
        {
            var categories = CategoryFaker.GetCategoryList(3);

            _output.WriteLine(JsonConvert.SerializeObject(categories, Formatting.Indented));

            Assert.Equal(3, categories.Count);
        }
        /// <summary>
        /// Generates products according to the given quantity with assigned concrete subcategory and category
        /// </summary>
        /// <param name="quantity">Number of products</param>
        /// <returns>products with assigned concrete subcategory and category</returns>
        public IEnumerable <Product> Generate(int quantity)
        {
            var subcategory = new SubcategoryFaker().UsePrivateConstructor().Generate();
            var category    = new CategoryFaker().UsePrivateConstructor().Generate();

            for (int i = 0; i < quantity; i++)
            {
                var product = new ProductFaker().UsePrivateConstructor().Generate();
                product.SetSubcategory(subcategory);
                product.Subcategory.SetCategory(category);

                yield return(product);
            }
        }
        public async void ListCategoryCommandHandler_ReturnAllCategories_MustReturnNotNull()
        {
            var categoryFaker      = new CategoryFaker();
            var categoryRepository = new Mock <ICategoryRepository>();

            categoryRepository.Setup(r => r.GetAll())
            .Returns(categoryFaker.GetAllMock());

            var listCategoryCommandHandler = new ListCategoryCommandHandler(categoryRepository.Object, AutoMapperSingleton.Mapper);

            // Act
            var tariffs = await listCategoryCommandHandler.Handle(
                new ListCategoryCommand()
            {
            }, new CancellationToken());

            // Assert
            Assert.NotNull(tariffs);
        }