Exemple #1
0
        public void IndexTest()
        {
            //Arrange
            PayController payController = new PayController();

            //Act
            ViewResult viewResult = payController.Index() as ViewResult;

            //Assert
            Assert.IsNotNull(viewResult);
        }
        public void IndexWithoutApplicationId()
        {
            var mockApproveUser = University.GetUser("e101");

            PayController controller = new PayController();

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

            RedirectToRouteResult result = controller.Index() as RedirectToRouteResult;

            Assert.IsNotNull(result);
            Assert.AreEqual("Sticker", result.RouteValues["controller"]);
            Assert.AreEqual("Index", result.RouteValues["action"]);
        }
        public void Index()
        {
            var mockApproveUser = University.GetUser("e201");

            //get Applications
            StickerController sc = new StickerController();

            sc.ControllerContext = new ControllerContext(MockAuthContext(mockApproveUser).Object, new RouteData(), sc);
            ViewResult indexResult = sc.Index() as ViewResult;

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

            //find application waiting for payment
            List <StickerApplication> listModel = indexResult.Model as List <StickerApplication>;

            Assert.AreNotEqual(0, listModel.Count);
            StickerApplication application = listModel.Find(m => m.Status == StickerApplicationStatus.WaitingForPayment);

            Assert.IsNotNull(application);

            PayController controller = new PayController();

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

            ViewResult result = controller.Index(application.ID) as ViewResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result.Model, typeof(PaymentRequest));

            PaymentRequest model = result.Model as PaymentRequest;

            Assert.IsNotNull(model.Application);
            Assert.IsNotNull(model.Application.Quota);
            Assert.IsNotNull(model.Application.Quota.StickerFee);
            Assert.AreEqual(model.Application.Quota.StickerFee, application.Quota.StickerFee);
        }