public async Task <ProductLineResponseModel> GetById(Guid id) { var productLineFound = await _productLineRepository.GetById(id); if (productLineFound != null) { var result = new ProductLineResponseModel { ProductCategoryName = productLineFound.ProductCategory?.CategoryName.ToString(), Name = productLineFound.Name.ToString() }; return(result); } _notificationService.AddNotification("ProductLineGetByIdError", $"Não foi encontrado nenhuma linha de produto com o id {id}"); return(null); }
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); }