public void PutInventory_ShouldFail_WhenDifferentID()
        {
            var controller = new InventoriesController(new TestInventory());

            var badresult = controller.PutInventory(999, GetInventoryItem());

            Assert.IsInstanceOfType(badresult, typeof(BadRequestResult));
        }
        public void PutInventory_ShouldReturnStatusCode()
        {
            var controller = new InventoriesController(new TestInventory());

            var item = GetInventoryItem();

            var result = controller.PutInventory(item.ID, item) as StatusCodeResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(StatusCodeResult));
            Assert.AreEqual(HttpStatusCode.NoContent, result.StatusCode);
        }
Ejemplo n.º 3
0
        public async void Task_Update_ValidData_Return_OkResult()
        {
            //Arrange
            var controller = new InventoriesController(repository);
            var inventId   = 2;

            //Act
            var existingPost = await controller.GetInventory(inventId);

            var okResult = existingPost.Result.Should().BeOfType <OkObjectResult>().Subject;

            var post = new Inventory();

            post.Name        = "Test name 2 Updated";
            post.Description = "description updated";
            post.Price       = 33;
            post.Image       = null;

            var updatedData = await controller.PutInventory(post);

            //Assert
            Assert.IsType <OkResult>(updatedData);
        }