Esempio n. 1
0
        public void BaseDefaultsModification_5()
        {
            MetaModel m   = MetaModel.Default;
            var       req = new FakeHttpWorkerRequest();
            var       ctx = new HttpContext(req);

            HttpContext.Current = ctx;

            RouteCollection routes = RouteTable.Routes;

            routes.Clear();

            var ddr = new DynamicDataRoute("{table}/{action}.aspx")
            {
                Action       = null,
                Model        = m,
                RouteHandler = new MyDynamicDataRouteHandler()
            };

            routes.Add(ddr);

            Assert.IsNotNull(ddr, "#A1");
            Assert.IsNull(ddr.Defaults, "#A1-1");
            var rd = new RouteData();
            var hc = new HttpContextWrapper(HttpContext.Current);

            ddr.GetVirtualPath(new RequestContext(hc, rd), null);
            Assert.IsNull(ddr.Defaults, "#B1");

            ddr.Action = "MyAction";
            ddr.GetVirtualPath(new RequestContext(hc, rd), null);
            Assert.IsNull(ddr.Defaults, "#C1");
        }
Esempio n. 2
0
        public void BaseDefaultsModification_8()
        {
            MetaModel m   = MetaModel.Default;
            var       req = new FakeHttpWorkerRequest();
            var       ctx = new HttpContext(req);

            HttpContext.Current = ctx;

            RouteCollection routes = RouteTable.Routes;

            routes.Clear();

            var ddr = new DynamicDataRoute("{table}/{action}.aspx")
            {
                Table        = String.Empty,
                Model        = m,
                RouteHandler = new MyDynamicDataRouteHandler()
            };

            routes.Add(ddr);
            var rd = new RouteData();
            var hc = new HttpContextWrapper(HttpContext.Current);

            AssertExtensions.Throws <ArgumentException> (() => {
                ddr.GetVirtualPath(new RequestContext(hc, rd), null);
            }, "#A1");
        }
Esempio n. 3
0
        public void BaseDefaultsModification_10()
        {
            MetaModel m   = MetaModel.Default;
            var       req = new FakeHttpWorkerRequest();
            var       ctx = new HttpContext(req);

            HttpContext.Current = ctx;

            RouteCollection routes = RouteTable.Routes;

            routes.Clear();

            var ddr = new DynamicDataRoute("{table}/{action}.aspx")
            {
                Defaults = new RouteValueDictionary()
                {
                    { "Table", "FooWithDefaultsTable" }
                },
                Table        = "BazTable",
                Model        = m,
                RouteHandler = new MyDynamicDataRouteHandler()
            };

            routes.Add(ddr);

            Assert.IsNotNull(ddr, "#A1");
            Assert.IsNotNull(ddr.Defaults, "#A1-1");
            var rd = new RouteData();
            var hc = new HttpContextWrapper(HttpContext.Current);

            ddr.GetVirtualPath(new RequestContext(hc, rd), null);
            Assert.IsNotNull(ddr.Defaults, "#B1");
            Assert.AreEqual(1, ddr.Defaults.Count, "#B1-1");
            Assert.AreEqual("BazTable", ddr.Defaults["Table"], "#B1-2");

            ddr.Table = "AnotherTable";
            ddr.GetVirtualPath(new RequestContext(hc, rd), null);
            Assert.IsNotNull(ddr.Defaults, "#C1");
            Assert.AreEqual(1, ddr.Defaults.Count, "#C1-1");
            Assert.AreEqual("BazTable", ddr.Defaults["Table"], "#C1-2");
        }
Esempio n. 4
0
        public void BaseDefaultsModification_9()
        {
            MetaModel m   = MetaModel.Default;
            var       req = new FakeHttpWorkerRequest();
            var       ctx = new HttpContext(req);

            HttpContext.Current = ctx;

            RouteCollection routes = RouteTable.Routes;

            routes.Clear();

            var ddr = new DynamicDataRoute("{table}/{action}.aspx")
            {
                Defaults = new RouteValueDictionary()
                {
                    { "Action", "InitialAction" }
                },
                Action       = PageAction.Details,
                Model        = m,
                RouteHandler = new MyDynamicDataRouteHandler()
            };

            routes.Add(ddr);

            Assert.IsNotNull(ddr, "#A1");
            Assert.IsNotNull(ddr.Defaults, "#A1-1");
            var rd = new RouteData();
            var hc = new HttpContextWrapper(HttpContext.Current);

            ddr.GetVirtualPath(new RequestContext(hc, rd), null);
            Assert.IsNotNull(ddr.Defaults, "#B1");
            Assert.AreEqual(1, ddr.Defaults.Count, "#B1-1");
            Assert.AreEqual(PageAction.Details, ddr.Defaults["Action"], "#B1-2");

            ddr.Action = "MyAction";
            ddr.GetVirtualPath(new RequestContext(hc, rd), null);
            Assert.IsNotNull(ddr.Defaults, "#C1");
            Assert.AreEqual(1, ddr.Defaults.Count, "#C1-1");
            Assert.AreEqual(PageAction.Details, ddr.Defaults["Action"], "#B1-2");
        }