Exemplo n.º 1
0
        public void TestEmpty()
        {
            filterContext.Setup(m => m.HttpContext).Returns(httpContext.Object);

            var navigatedAttribute = new NavigatedAttribute();
            navigatedAttribute.OnActionExecuting(filterContext.Object);

            Assert.AreEqual(1, controller.Object.ViewBag.PageNumber);
            Assert.AreEqual(navigatedAttribute.PageSize, controller.Object.ViewBag.PageSize);

            var gso = controller.Object.ViewBag.GridSortOptions as GridSortOptions;
            Assert.IsNotNull(gso);
            Assert.AreEqual(SortDirection.Descending, gso.Direction);
            Assert.IsNull(gso.Column);
        }
Exemplo n.º 2
0
        public void TestParsingPageAndSize()
        {
            filterContext.Setup(m => m.HttpContext).Returns(httpContext.Object);
            httpRequest.SetupGet(m => m["page"]).Returns("2");
            httpRequest.SetupGet(m => m["size"]).Returns("4");

            var navigatedAttribute = new NavigatedAttribute();
            navigatedAttribute.OnActionExecuting(filterContext.Object);

            Assert.AreEqual(2, controller.Object.ViewBag.PageNumber);
            Assert.AreEqual(4, controller.Object.ViewBag.PageSize);

            var gso = controller.Object.ViewBag.GridSortOptions as GridSortOptions;
            Assert.IsNotNull(gso);
            Assert.AreEqual(SortDirection.Descending, gso.Direction);
            Assert.IsNull(gso.Column);
        }
Exemplo n.º 3
0
        public void TestSortColumnAndDirection()
        {
            filterContext.Setup(m => m.HttpContext).Returns(httpContext.Object);
            httpRequest.SetupGet(m => m["column"]).Returns("mycolumn");
            httpRequest.SetupGet(m => m["direction"]).Returns("ascending");

            var navigatedAttribute = new NavigatedAttribute();
            navigatedAttribute.OnActionExecuting(filterContext.Object);

            Assert.AreEqual(1, controller.Object.ViewBag.PageNumber);
            Assert.AreEqual(navigatedAttribute.PageSize, controller.Object.ViewBag.PageSize);

            var gso = controller.Object.ViewBag.GridSortOptions as GridSortOptions;
            Assert.IsNotNull(gso);
            Assert.AreEqual(SortDirection.Ascending, gso.Direction);
            Assert.AreEqual("mycolumn", gso.Column);
        }