public void TestCloseGet_UnauthorizedAccountOwner() { #region ASSIGN TestRepository tRepo = new TestRepository(); AccountsController tController = null; tController = new AccountsController(tRepo) { ControllerContext = UtilityFunctions.GenerateMockControllerContext("User"), }; #endregion #region ACT var tResult = tController.Close(0); #endregion #region ASSERT Assert.IsTrue(tResult is RedirectToActionResult); Assert.AreEqual((tResult as RedirectToActionResult).ActionName, "Index"); #endregion }
public void TestCloseGet_Valid() { #region ASSIGN TestRepository tRepo = new TestRepository(); AccountsController tController = null; tController = new AccountsController(tRepo) { ControllerContext = UtilityFunctions.GenerateMockControllerContext("UserA"), }; #endregion #region ACT var tResult = tController.Close(0); #endregion #region ASSERT Assert.IsTrue(tResult is ViewResult); Assert.AreEqual(((tResult as ViewResult).Model as Account).ID, 0); Assert.AreEqual(((tResult as ViewResult).Model as Account).CustomerID, 0); #endregion }
public void TestClosePost_Valid() { #region ASSIGN TestRepository tRepo = new TestRepository(); AccountsController tController = null; Account tData = tRepo.GetAccountInformation(0, 0); tData.AccountBalance = 0.0; tController = new AccountsController(tRepo) { ControllerContext = UtilityFunctions.GenerateMockControllerContext("UserA"), }; #endregion #region ACT var tResult = tController.Close(0, tData); #endregion #region ASSERT Assert.IsTrue(tResult is RedirectToActionResult); Assert.AreEqual((tResult as RedirectToActionResult).ActionName, "Index"); Assert.AreEqual((tResult as RedirectToActionResult).ControllerName, "Customers"); #endregion }