Esempio n. 1
0
        private async void Edit_UserEditPlaningModelInput_ViewResult()
        {
            var model = new PlanningEditModel();
            var user  = new WebUser()
            {
                Id = "1"
            };
            var target = new PlaningController(null, null, null);

            target.ModelState.AddModelError("", "");

            var result = await target.Edit(user, model);

            var modelState = ((ViewResult)result).ViewData.ModelState.IsValid;

            Assert.IsFalse(modelState);
            Assert.IsInstanceOfType(result, typeof(ViewResult));
        }
Esempio n. 2
0
        private async void Edit_UserEditPlaningModelInput_ModelSpread_RedirectToAction()
        {
            Mock <IPlanItemService> mockPlan   = new Mock <IPlanItemService>();
            Mock <IPlanningHelper>  mockHelper = new Mock <IPlanningHelper>();
            var user  = new WebUser();
            var model = new PlanningEditModel()
            {
                PlanItem = new PlanItem(),
                Spread   = true
            };
            var target = new PlaningController(null, mockPlan.Object, mockHelper.Object);

            target.ControllerContext = GetControllerContext(target);

            var result = await target.Edit(user, model);

            mockHelper.Verify(m => m.SpreadPlanItems(user, model.PlanItem));
            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
            Assert.AreEqual(((RedirectToRouteResult)result).RouteValues["action"], "ViewPlan");
        }
Esempio n. 3
0
        private async void Edit_IdInput_PartialViewResulEditPlaningModeltReturned()
        {
            Mock <IPlanItemService> mockPlanItem = new Mock <IPlanItemService>();

            mockPlanItem.Setup(m => m.GetItemAsync(It.IsAny <int>())).ReturnsAsync(new PlanItem()
            {
                PlanItemID = 1
            });
            var target = new PlaningController(null, mockPlanItem.Object, null);
            var user   = new WebUser()
            {
                Id = "1"
            };

            var result = await target.Edit(1);

            var model = ((PartialViewResult)result).ViewData.Model as PlanningEditModel;

            Assert.AreEqual(model?.PlanItem.PlanItemID, 1);
            Assert.IsInstanceOfType(result, typeof(PartialViewResult));
        }