public void GetCustomersByID_Valid() { #region ASSIGN CustomerRepo testRepo = new CustomerRepo(); CustomersApiController testController = new CustomersApiController(testRepo); #endregion #region ACT var taskReturn = testController.GetCustomer(1); taskReturn.Wait(); var result = taskReturn.Result.Value; Customer testData = result; #endregion #region ASSERT Assert.AreEqual(testData.Id, 1); Assert.AreEqual(testData.Name, "John Doe"); Assert.AreEqual(testData.UserName, "*****@*****.**"); Assert.AreEqual(testData.Street, "123 A Street"); Assert.AreEqual(testData.City, "Here"); Assert.AreEqual(testData.StateID, 1); Assert.AreEqual(testData.ZipCode, 10000); #endregion }
public void GetCustomers() { #region ASSIGN CustomerRepo testRepo = new CustomerRepo(); CustomersApiController testController = new CustomersApiController(testRepo); #endregion #region ACT var taskReturn = testController.GetCustomer(); taskReturn.Wait(); var result = taskReturn.Result.Value; List <Customer> testList = new List <Customer>(result); #endregion #region ASSERT Assert.AreEqual(testList.Count, 2); Assert.AreEqual(testList[0].Id, 1); Assert.AreEqual(testList[0].Name, "John Doe"); Assert.AreEqual(testList[0].UserName, "*****@*****.**"); Assert.AreEqual(testList[0].Street, "123 A Street"); Assert.AreEqual(testList[0].City, "Here"); Assert.AreEqual(testList[0].StateID, 1); Assert.AreEqual(testList[0].ZipCode, 10000); Assert.AreEqual(testList[1].Id, 2); Assert.AreEqual(testList[1].Name, "Mary Sue"); Assert.AreEqual(testList[1].UserName, "*****@*****.**"); Assert.AreEqual(testList[1].Street, "345 B Avenue"); Assert.AreEqual(testList[1].City, "There"); Assert.AreEqual(testList[1].StateID, 2); Assert.AreEqual(testList[1].ZipCode, 20000); #endregion }
public void GetCustomersByID_NonExistentUser() { #region ASSIGN CustomerRepo testRepo = new CustomerRepo(); CustomersApiController testController = new CustomersApiController(testRepo); #endregion #region ACT var taskReturn = testController.GetCustomer(0); taskReturn.Wait(); var result = taskReturn.Result.Result; #endregion #region ASSERT Assert.IsTrue(result is NotFoundResult); Assert.AreEqual((result as NotFoundResult).StatusCode, 404); #endregion }