public void DeleteCustomer_Valid() { #region ASSIGN CustomerRepo testRepo = new CustomerRepo(); CustomersApiController testController = new CustomersApiController(testRepo); #endregion #region ACT var taskReturn = testController.DeleteCustomer(1); taskReturn.Wait(); var resultData = taskReturn.Result.Value; Customer checkData = testRepo.SelectById(1).Result; #endregion #region ASSERT Assert.AreEqual(resultData.Id, 1); Assert.AreEqual(resultData.Name, "John Doe"); Assert.AreEqual(resultData.UserName, "*****@*****.**"); Assert.AreEqual(resultData.Street, "123 A Street"); Assert.AreEqual(resultData.City, "Here"); Assert.AreEqual(resultData.StateID, 1); Assert.AreEqual(resultData.ZipCode, 10000); Assert.IsNull(checkData); #endregion }
public void DeleteCustomer_NonExistingCustomer() { #region ASSIGN CustomerRepo testRepo = new CustomerRepo(); CustomersApiController testController = new CustomersApiController(testRepo); #endregion #region ACT var taskReturn = testController.DeleteCustomer(0); taskReturn.Wait(); var resultStatus = taskReturn.Result.Result; var checkData = testRepo.SelectAll().Result; #endregion #region ASSERT Assert.IsTrue(resultStatus is NotFoundResult); Assert.AreEqual((resultStatus as NotFoundResult).StatusCode, 404); Assert.AreEqual(checkData.Count, 2); Assert.AreEqual(checkData[0].Id, 1); Assert.AreEqual(checkData[0].Name, "John Doe"); Assert.AreEqual(checkData[0].UserName, "*****@*****.**"); Assert.AreEqual(checkData[0].Street, "123 A Street"); Assert.AreEqual(checkData[0].City, "Here"); Assert.AreEqual(checkData[0].StateID, 1); Assert.AreEqual(checkData[0].ZipCode, 10000); Assert.AreEqual(checkData[1].Id, 2); Assert.AreEqual(checkData[1].Name, "Mary Sue"); Assert.AreEqual(checkData[1].UserName, "*****@*****.**"); Assert.AreEqual(checkData[1].Street, "345 B Avenue"); Assert.AreEqual(checkData[1].City, "There"); Assert.AreEqual(checkData[1].StateID, 2); Assert.AreEqual(checkData[1].ZipCode, 20000); #endregion }