Exemplo n.º 1
0
        public void ServiceShouldReturnNullWhenIdNotExist()
        {
            var product = new ProductForCreate();

            product.ApoClassCode       = "200";
            product.BrandId            = 2;
            product.ProductCode        = "304981";
            product.ProductDescription = "BraBra";
            product.ProductName        = "HoHo";

            var service = new ProductService(_productRepository, _attributeTypeService, _attributeValueService);

            var sut = service.Edit(122222, product) as ProductDto;

            Assert.Null(sut);
        }
Exemplo n.º 2
0
        public void ServiceShouldReturnNewProductWhenAddSuccess()
        {
            var newProduct = new ProductForCreate();

            newProduct.ApoClassCode       = "200";
            newProduct.BrandId            = 2;
            newProduct.ProductCode        = "304981";
            newProduct.ProductDescription = "BraBra";
            newProduct.ProductName        = "HoHo";

            var lastId = _productDomains.Last().Id;

            var service = new ProductService(_productRepository, _attributeTypeService, _attributeValueService);

            var sut = service.Create(newProduct);

            Assert.True(sut.Id == lastId + 1);
            Assert.Equal(sut.ApoClassCode, newProduct.ApoClassCode);
            Assert.Equal(sut.ProductName, newProduct.ProductName);
            Assert.Equal(sut.BrandId, newProduct.BrandId);
            Assert.Equal(sut.ProductCode, newProduct.ProductCode);
        }
Exemplo n.º 3
0
        public void ServiceShouldReturnCorrectValueWhenEditSuccess()
        {
            var product = new ProductForCreate();

            product.ApoClassCode       = "200";
            product.BrandId            = 2;
            product.ProductCode        = "304981";
            product.ProductDescription = "BraBra";
            product.ProductName        = "HoHo";

            var service = new ProductService(_productRepository, _attributeTypeService, _attributeValueService);

            var sut = service.Edit(1, product) as ProductDto;

            var result = new ProductDto();

            result.ApoClassCode = product.ApoClassCode;
            result.BrandId      = product.BrandId;
            result.ProductCode  = product.ProductCode;
            result.Id           = 1;
            result.ProductName  = product.ProductName;

            AssertObjects.PropertyValuesAreEquals(result, sut);
        }