public void PostOrder_Valid() { #region ASSIGN OrdersRepo testRepo = new OrdersRepo(); OrdersApiController testController = new OrdersApiController(testRepo); Orders testData = new Orders() { Id = 6, CustomerId = 5, DeliveryAddress = "221 Baker Street", isCompleted = true, NetPrice = 99.99M, TimePlaced = DateTime.Now, }; #endregion #region ACT var taskReturn = testController.PostOrder(testData); taskReturn.Wait(); var result = taskReturn.Result.Result; Orders checkData = testRepo.SelectById(6).Result; #endregion #region ASSERT Assert.IsTrue(result is CreatedAtActionResult); Assert.AreEqual((result as CreatedAtActionResult).StatusCode, 201); Assert.AreEqual((result as CreatedAtActionResult).RouteValues["id"], 6); var testReturn = ((result as CreatedAtActionResult).Value as Orders); Assert.AreEqual(testReturn.Id, 6); Assert.AreEqual(testReturn.CustomerId, 5); Assert.AreEqual(testReturn.NetPrice, 99.99M); Assert.IsTrue(testReturn.isCompleted); Assert.AreEqual(checkData.Id, 6); Assert.AreEqual(checkData.CustomerId, 5); Assert.AreEqual(checkData.NetPrice, 99.99M); Assert.IsTrue(checkData.isCompleted); #endregion }