예제 #1
0
        public void MustNotCreateProduct_WithoutSku()
        {
            var product = ProductServiceBuilder.newProduct()
                          .WithName(_name)
                          .WithInventoryWithoutQuantity(_inventoryWithQuantityInvalid)
                          .Build();

            _productController.Post(product);

            var act = (_productController.Post(product) as BadRequestObjectResult).StatusCode;
            var exp = new BadRequestResult().StatusCode;

            Assert.Equal(exp, act);
        }
예제 #2
0
        public void MustNotUpdateProduct_UsingInvalidSku(int invalidSku)
        {
            var product = ProductServiceBuilder.newProduct()
                          .WithSku(invalidSku)
                          .WithName(_name)
                          .Marketable(_inventory)
                          .Build();

            _productController.Post(product);

            var act = (_productController.Update(product) as BadRequestObjectResult).StatusCode;
            var exp = new BadRequestResult().StatusCode;

            Assert.Equal(exp, act);
        }
예제 #3
0
        public void CreateProductWithTheSameSku()
        {
            var product = ProductServiceBuilder.newProduct()
                          .WithSku(_sku)
                          .WithName(_name)
                          .Marketable(_inventory)
                          .Build();

            _productController.Post(product);

            var act = (_productController.Post(product) as BadRequestObjectResult).StatusCode;
            var exp = new BadRequestResult().StatusCode;

            Assert.Equal(exp, act);
        }
예제 #4
0
        public void GetProductBySku_UsingInventoryWithoutQuantity()
        {
            var product = ProductServiceBuilder.newProduct()
                          .WithSku(100)
                          .WithName(_name)
                          .WithInventoryWithoutQuantity(_inventoryWithQuantityInvalid)
                          .Build();

            _productController.Post(product);

            var act = (_productController.Get(product.Sku).Result as OkObjectResult).Value as Product;

            Assert.Equal(0, act.Inventory.Quantity);
            Assert.False(act.IsMarketable);
        }
예제 #5
0
        public void MustDeleteProduct()
        {
            //Arrange
            var product = ProductServiceBuilder.newProduct()
                          .WithSku(_sku)
                          .WithName(_name)
                          .Marketable(_inventory)
                          .Build();

            _productController.Post(product);

            var act = (_productController.Delete(_sku) as OkObjectResult).StatusCode;
            var exp = new OkResult().StatusCode;

            Assert.Equal(exp, act);
        }
예제 #6
0
        public void MustGetProductBySkuNumber()
        {
            //Arrange
            var product = ProductServiceBuilder.newProduct()
                          .WithSku(_sku)
                          .WithName(_name)
                          .Marketable(_inventory)
                          .Build();

            _productController.Post(product);

            //Act
            var act = (_productController.Get(_sku).Result as OkObjectResult).Value as Product;

            //Assert
            product.ToExpectedObject().Matches(act);
            Assert.Equal(15, act.Inventory.Quantity);
            Assert.True(act.IsMarketable);
        }