public void Integration_ShouldInsertNewEatableItemWhenPost() { var getResponse = _controller.Get(); var beforePostInventory = ((OkNegotiatedContentResult <IList <Web.Models.Eatable> >)getResponse).Content.ToList(); var newEatable = new Web.Models.EatableInput { Name = "new-cockie", Price = 1.00M }; var response = _controller.Post(newEatable); var result = ((OkNegotiatedContentResult <Web.Models.Eatable>)response).Content; Assert.IsNotNull(result); Assert.IsTrue(result.Id != 0); Assert.IsTrue(result.Name == newEatable.Name); Assert.IsTrue(result.Price == newEatable.Price); Assert.IsNull(beforePostInventory.FirstOrDefault(i => i.Id == result.Id)); }
public void Integration_ShouldUpdateEatableItem() { var newEatable = new Web.Models.EatableInput { Name = "new-cockie", Price = 1.00M }; var updatedEatable = new Web.Models.EatableInput { Name = "new-cockie with seasalt", Price = 1.50M }; var newResponse = _controller.Post(newEatable); var newResult = ((OkNegotiatedContentResult <Web.Models.Eatable>)newResponse).Content; var response = _controller.Put(newResult.Id, updatedEatable); var inventoryList = ((OkNegotiatedContentResult <IList <Web.Models.Eatable> >)response).Content.ToList(); Assert.IsNotNull(inventoryList); Assert.IsTrue(inventoryList.Count > 0); Assert.IsNotNull(inventoryList.Where(i => (i.Name == updatedEatable.Name)).FirstOrDefault()); }