Ejemplo n.º 1
0
        public void TestIndex_Login_Failed()
        {
            //arrange
            var target = new LoginController();
            var id = "joey";
            var password = "******";

            //act
            var actual = target.Index(id, password) as ViewResult;

            //assert
            //檢查 actual 的 ViewBag.Message 是否為 "帳號或密碼有誤"

            Assert.AreEqual("帳號或密碼有誤", actual.ViewBag.Message);
        }
Ejemplo n.º 2
0
        public void TestIndex_Login_Success()
        {
            //arrange
            var target = new LoginController();
            var id = "joey";
            var password = "******";

            //act
            var actual = target.Index(id, password) as RedirectToRouteResult;

            //assert
            //檢查 actual 的 actionName 是否為 Index, controllerName 是否為 Home
            var expectedActionName = "Index";
            Assert.AreEqual(expectedActionName, actual.RouteValues["Action"]);

            var expectedControllerName = "Home";
            Assert.AreEqual(expectedControllerName, actual.RouteValues["Controller"]);
        }