Ejemplo n.º 1
0
        public void GetPage_nullPageState_null()
        {
            PageState testPageState     = null;
            var       codeList          = new List <Code>();
            var       codeViewModelList = new List <CodeViewModel>();

            mockUnitOfWork.Setup(m => m.Codes.Get(It.IsAny <Expression <Func <Code, bool> > >(), It.IsAny <Func <IQueryable <Code>,
                                                                                                                 IOrderedQueryable <Code> > >(), It.IsAny <string>())).Returns(codeList);
            mockUnitOfWork.Setup(m => m.Operators.GetById(It.Is <int>(x => x == testPageState.OperatorId))).Returns(new Operator {
                Name = "Zhora"
            });
            mockMapper.Setup(m => m.Map <IEnumerable <Code>,
                                         IEnumerable <CodeViewModel> >(It.Is <IEnumerable <Code> >(x => x.Equals(codeList)))).Returns(codeViewModelList);

            var result = manager.GetPage(testPageState);

            Assert.That(result, Is.Null);
        }
Ejemplo n.º 2
0
        public IActionResult Codes(PageState pageState)
        {
            if (ModelState.IsValid)
            {
                if (TempData.ContainsKey("OperatorId"))
                {
                    pageState.OperatorId = Convert.ToInt32(TempData["OperatorId"]);
                }

                var page = codeManager.GetPage(pageState);

                ViewBag.Codes     = page.CodeList;
                ViewBag.PageState = page.PageState;
                return(View());
            }
            TempData["ErrorMessage"] = "Internal error";
            return(RedirectToAction("Operators", "Operator"));
        }