예제 #1
0
        public void IndexFilteredThenReject()
        {
            var mockDeliverUser = University.GetUser("o102");

            DeliverController controller = new DeliverController();

            controller.ControllerContext = new ControllerContext(MockAuthContext(mockDeliverUser).Object, new RouteData(), controller);

            ViewResult result = controller.Index("", "", "Test Student13", 1) as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model, typeof(PagedList <StickerApplication>));

            PagedList <StickerApplication> model = result.Model as PagedList <StickerApplication>;

            Assert.AreEqual(0, model.Where(a => a.Status != StickerApplicationStatus.WaitingForDelivery).Count());
            Assert.AreEqual(1, model.Count);

            controller.Reject(model.FirstOrDefault().ID);
            result = controller.Index("", "", "Test Student13", 1) as ViewResult;
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model, typeof(PagedList <StickerApplication>));

            model = result.Model as PagedList <StickerApplication>;
            Assert.AreEqual(0, model.Count);
        }
예제 #2
0
        public void IndexFilteredThenApprove()
        {
            var mockDeliverUser = University.GetUser("o102");

            DeliverController controller = new DeliverController();

            controller.ControllerContext = new ControllerContext(MockAuthContext(mockDeliverUser).Object, new RouteData(), controller);

            //get list
            ViewResult result = controller.Index("", "", "Test Student13", 1) as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model, typeof(PagedList <StickerApplication>));

            PagedList <StickerApplication> model = result.Model as PagedList <StickerApplication>;

            Assert.AreEqual(0, model.Where(a => a.Status != StickerApplicationStatus.WaitingForDelivery).Count());
            Assert.AreEqual(1, model.Count);

            //deliver
            StickerApplication stickerApplication = model.FirstOrDefault();

            controller.Deliver(stickerApplication.ID, new Sticker {
                SerialNumber = 1
            });

            //get list
            result = controller.Index("", "", "Test Student13", 1) as ViewResult;
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model, typeof(PagedList <StickerApplication>));
            model = result.Model as PagedList <StickerApplication>;
            Assert.AreEqual(0, model.Count);

            //applications index page for user
            StickerController scontroller = new StickerController
            {
                ControllerContext = new ControllerContext(MockAuthContext(University.GetUser(stickerApplication.User.UID)).Object, new RouteData(), controller)
            };
            ViewResult sresult = scontroller.Index() as ViewResult;

            Assert.IsNotNull(sresult);
            Assert.IsInstanceOfType(sresult.Model, typeof(List <StickerApplication>));

            List <StickerApplication> smodel = sresult.Model as List <StickerApplication>;

            Assert.AreNotEqual(0, smodel.Count);
            Assert.AreEqual(StickerApplicationStatus.Active, smodel.FirstOrDefault().Status);
            Assert.AreEqual(1, smodel.FirstOrDefault().Sticker.SerialNumber);
        }
예제 #3
0
        public void ApproveWithStickerInUse()
        {
            var mockDeliverUser = University.GetUser("o102");

            DeliverController controller = new DeliverController();

            controller.ControllerContext = new ControllerContext(MockAuthContext(mockDeliverUser).Object, new RouteData(), controller);

            //get list
            ViewResult result = controller.Index("", "", "Test Student13", 1) as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model, typeof(PagedList <StickerApplication>));

            PagedList <StickerApplication> model = result.Model as PagedList <StickerApplication>;

            Assert.AreEqual(0, model.Where(a => a.Status != StickerApplicationStatus.WaitingForDelivery).Count());
            Assert.AreEqual(1, model.Count);

            //deliver
            StickerApplication    stickerApplication = model.FirstOrDefault();
            RedirectToRouteResult routeResult        = controller.Deliver(stickerApplication.ID, new Sticker {
                SerialNumber = 12345
            }) as RedirectToRouteResult;

            Assert.IsNotNull(routeResult);
            Assert.IsNotNull(routeResult.RouteValues["stickerInUse"]);
        }