Esempio n. 1
0
        public async Task should_update_product_line()
        {
            var ProductCategoryId = Guid.NewGuid();
            var ProductLineId     = Guid.NewGuid();
            var model             = new ProductLineRequestModel
            {
                Name = "Nokia 210",
                ProductCategoryId = ProductCategoryId
            };

            var productLineToUpdate = new ProductLineBuilder()
                                      .WithName("nokia A")
                                      .WithProductCategoryId(ProductCategoryId)
                                      .Construct();


            _productLineRepository.ValidateEntityExistence(ProductCategoryId).Returns(true);
            _productLineRepository.GetById(ProductLineId).Returns(productLineToUpdate);

            await _productLineService.Update(ProductLineId, model);

            await _productLineRepository
            .Received(1)
            .Update(Arg.Is <ProductLine>(x => x.ProductCategoryId == ProductCategoryId &&
                                         x.Name.ToString() == model.Name));
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }