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); }
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); }
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); }
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); }
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); }
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); }