Exemplo n.º 1
0
        public void TestLoginView()
        {
            //var helper = new MockHelper();
            //var context = helper.MakeFakeContext();
            var controller = new SEP_Team1.Controllers.HomeController();

            //controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);
            ViewResult result = controller.Login() as ViewResult;

            Assert.AreEqual("", result.ViewName.ToString());
        }
Exemplo n.º 2
0
        public void TestListStudent()
        {
            var helper     = new MockHelper();
            var context    = helper.MakeFakeContext();
            var controller = new SEP_Team1.Controllers.HomeController();

            context.SetupGet(x => x.Session["MaGV"]).Returns("MH");

            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);
            ViewResult result = controller.ListStudent("MH1") as ViewResult;

            Assert.AreEqual("", result.ViewName.ToString());
        }
Exemplo n.º 3
0
        public void TestCreateAttendanceWithWrongID()
        {
            var helper     = new MockHelper();
            var context    = helper.MakeFakeContext();
            var controller = new SEP_Team1.Controllers.HomeController();

            context.SetupGet(x => x.Session["MaGV"]).Returns("MH");
            //context.SetupGet(x => x.Session["MaKH"]).Returns("MH3");

            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);
            RedirectToRouteResult result = controller.CreateAttendance("ddas") as RedirectToRouteResult;

            Assert.AreEqual("", result.RouteName);
        }
Exemplo n.º 4
0
        public void Logout()
        {
            var helper     = new MockHelper();
            var context    = helper.MakeFakeContext();
            var controller = new SEP_Team1.Controllers.HomeController();
            var Username   = "******";
            var password   = "******";

            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);
            var redirectRoute         = controller.Login(Username, password) as RedirectToRouteResult;
            var redirectToRouteResult = controller.Logout() as RedirectToRouteResult;

            Assert.AreEqual("Login", redirectToRouteResult.RouteValues["action"]);
        }
Exemplo n.º 5
0
        public void TestViewCourses()
        {
            var helper     = new MockHelper();
            var context    = helper.MakeFakeContext();
            var controller = new SEP_Team1.Controllers.HomeController();

            string id = "SP";

            context.SetupGet(x => x.Session["MaGV"]).Returns("GV123");
            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);
            ViewResult result = controller.Course(id) as ViewResult;

            Assert.AreEqual("", result.ViewName.ToString());
        }
Exemplo n.º 6
0
        public void TestInvalidAccount_WithWrongPassWord()
        {
            var helper     = new MockHelper();
            var context    = helper.MakeFakeContext();
            var controller = new SEP_Team1.Controllers.HomeController();
            //context.SetupGet(x => x.Session["hoten"]).Returns("username");
            //context.SetupGet(x => x.Session["MaGV"]).Returns("item.data.id");
            var Username = "******";
            var password = "******";

            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);
            ViewResult view = controller.Login(Username, password) as ViewResult;

            Assert.AreEqual("", view.ViewName);
            Assert.AreEqual("Incorrect username or password", controller.ViewBag.mgs);
        }
Exemplo n.º 7
0
        public void TestViewdiemDanh()
        {
            var helper     = new MockHelper();
            var context    = helper.MakeFakeContext();
            var controller = new SEP_Team1.Controllers.HomeController();

            context.SetupGet(x => x.Session["MaGV"]).Returns("MH");
            context.SetupGet(x => x.Session["MaKH"]).Returns("MH2");


            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);

            ViewResult result = controller.diemDanh("2") as ViewResult;

            Assert.AreEqual("", result.ViewName);
        }
Exemplo n.º 8
0
        public void TestLogin()
        {
            //var Controller = new HomeController();
            //String ID = "phamminhhuyen";
            //String Pass = "******";
            //var result = Controller.Login() as ViewResult;
            //var result1 = Controller.Login(ID, Pass) as RedirectToRouteResult ;
            //Assert.AreEqual("Index", result1.RouteValues["action"]);
            //Assert.AreEqual("Home", result1.RouteValues["controller"]);
            var helper     = new MockHelper();
            var context    = helper.MakeFakeContext();
            var controller = new SEP_Team1.Controllers.HomeController();
            var Username   = "******";
            var password   = "******";

            controller.ControllerContext = new ControllerContext(context.Object, new RouteData(), controller);

            var redirectRoute = controller.Login(Username, password) as RedirectToRouteResult;

            Assert.IsNotNull(redirectRoute);
            Assert.AreEqual("Index", redirectRoute.RouteValues["action"]);
            Assert.AreEqual("Home", redirectRoute.RouteValues["controller"]);
        }