Example #1
0
        private async Task MethodPrepare_UserWithCategoriesWithNoPlanItems_CreatePlanReturned(WebUser user)
        {
            Mock <IPlanItemService> mockPlanItem = new Mock <IPlanItemService>();
            Mock <ICategoryService> mockCategory = new Mock <ICategoryService>();

            mockCategory.Setup(m => m.GetListAsync()).ReturnsAsync(_categories);
            var target = new PlaningController(mockCategory.Object, mockPlanItem.Object, null);

            var result = await target.Prepare(user);

            var controller = ((RedirectToRouteResult)result).RouteValues["controller"];
            var action     = ((RedirectToRouteResult)result).RouteValues["action"];

            Assert.IsNull(controller);
            Assert.AreEqual("CreatePlan", action);
        }
Example #2
0
        private async Task MethodPrepare_WithCategories_WithPlanItems(WebUser user)
        {
            Mock <IPlanItemService> mockPlanItem = new Mock <IPlanItemService>();
            Mock <ICategoryService> mockCategory = new Mock <ICategoryService>();

            mockCategory.Setup(m => m.GetListAsync()).ReturnsAsync(_categories);
            mockPlanItem.Setup(m => m.GetListAsync(It.IsAny <Expression <Func <PlanItem, bool> > >())).ReturnsAsync(_planItems);
            var target = new PlaningController(mockCategory.Object, mockPlanItem.Object, null);

            var result = await target.Prepare(user);

            var controller = ((RedirectToRouteResult)result).RouteValues["controller"];
            var action     = ((RedirectToRouteResult)result).RouteValues["action"];

            Assert.IsNull(controller);
            Assert.AreEqual("ViewPlan", action);
        }
Example #3
0
        private async Task Prepare_UserWithNoCategories_PayingItemListReturned(WebUser user)
        {
            var mockCategory = new Mock <ICategoryService>();
            var mockPlanItem = new Mock <IPlanItemService>();

            mockPlanItem.Setup(m => m.GetListAsync(It.IsAny <Expression <Func <PlanItem, bool> > >())).ReturnsAsync(new List <PlanItem>());
            mockCategory.Setup(m => m.GetListAsync()).ReturnsAsync(new List <Category>());
            var target = new PlaningController(mockCategory.Object, mockPlanItem.Object, null);

            var result = await target.Prepare(user);

            var controller = ((RedirectToRouteResult)result).RouteValues["controller"];
            var action     = ((RedirectToRouteResult)result).RouteValues["action"];

            Assert.AreEqual("Index", action);
            Assert.AreEqual("PayingItem", controller);
        }