public async Task <IList <ProductLineResponseModel> > GetAll()
        {
            var productsLines = await _productLineRepository.GetAll();

            if (productsLines != null)
            {
                return(productsLines.Select(d => new ProductLineResponseModel
                {
                    Name = d.Name.ToString(),
                    ProductCategoryName = d.ProductCategory.CategoryName.ToString()
                }).ToList());
            }
            _notificationService.AddNotification("ProductLineGetAllError", "Não há linhas de produtos cadastradas na base");
            return(null);
        }
Esempio n. 2
0
        public async Task ShoudGetAll()
        {
            var productCategory = new CategoryProductBuilder()
                                  .WithName("celular")
                                  .Construct();


            var productLine = new ProductLineBuilder().
                              WithProductCategoryId(Guid.NewGuid())
                              .WithName("nokia 780")
                              .WhithCategory(productCategory)
                              .Construct();

            var productLine2 = new ProductLineBuilder().
                               WithProductCategoryId(Guid.NewGuid())
                               .WithName("nokia 7080")
                               .WhithCategory(productCategory)
                               .Construct();

            var productLineResponse = new ProductLineResponseModel
            {
                Name = "nokia 780",
                ProductCategoryName = productCategory.CategoryName.ToString()
            };

            var productsList = new List <ProductLine>();

            productsList.Add(productLine);
            productsList.Add(productLine2);

            _productLineRepository.GetAll().Returns(productsList);

            var result = await _productLineService.GetAll();

            result[0].Should().BeEquivalentTo(productLineResponse);
        }