public async Task ShouldUpdateProduct()
        {
            var productId  = Guid.NewGuid();
            var supplierId = Guid.NewGuid();
            var model      = new ProductCategoryRequestModel
            {
                SupplierId   = Guid.NewGuid(),
                CategoryName = "celular"
            };

            var product = new CategoryProductBuilder()
                          .WithSupplier(supplierId)
                          .WithName("carro")
                          .Construct();

            _productRepository
            .GetById(supplierId)
            .Returns(product);

            _productRepository.ValidateEntityExistence(productId).Returns(true);

            _productRepository.GetById(productId).Returns(product);

            await _productService.Update(productId, model);

            await _productRepository
            .Received(1)
            .Update(Arg.Is <ProductCategory>(x => x.CategoryName.ToString() == "celular"));
        }
        public async Task ShouldGetProductPorId()
        {
            var supplierId = Guid.NewGuid();
            var productId  = Guid.NewGuid();
            var user       = new CategoryProductBuilder()
                             .WithSupplier(supplierId)
                             .WithName("celular")
                             .Construct();

            _productRepository
            .GetById(productId)
            .Returns(user);

            var productRetornado = await _productService.GetById(productId);

            Assert.Equal("celular", productRetornado.CategoryName);
        }
Ejemplo n.º 3
0
        public async Task ShoudGetById()
        {
            var productLineId   = Guid.NewGuid();
            var productCategory = new CategoryProductBuilder()
                                  .WithName("celular")
                                  .Construct();

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

            _productLineRepository.GetById(productLineId).Returns(productLine);

            var productLineFound = await _productLineService.GetById(productLineId);

            Assert.Equal("nokia 780", productLineFound.Name);
        }
Ejemplo n.º 4
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);
        }