Exemple #1
0
        public void GetActionPath2()
        {
            var foo = new Foo(true);
            var req = new FakeHttpWorkerRequest();
            var ctx = new HttpContext(req);

            HttpContext.Current = ctx;
            MetaModel m = Utils.GetModel <MyDataContext2> ();

            RouteTable.Routes.Add(
                new DynamicDataRoute("{table}/{action}.aspx")
            {
                Constraints  = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }),
                Model        = m,
                RouteHandler = new MyDynamicDataRouteHandler()
            });

            // .NET stacktrace:
            //
            // at System.Web.DynamicData.MetaModel.TryGetTable(String uniqueTableName, MetaTable& table)
            // at System.Web.DynamicData.MetaModel.GetTable(String uniqueTableName)
            AssertExtensions.Throws <ArgumentNullException> (() => m.GetActionPath(null, PageAction.List, foo), "#A1");
            Assert.AreEqual(String.Empty, m.GetActionPath("FooTable", null, foo), "#A2");
            Assert.AreEqual("/FooTable/List.aspx", m.GetActionPath("FooTable", PageAction.List, null), "#A3");
            AssertExtensions.Throws <ArgumentException> (() => m.GetActionPath("NoSuchTable", PageAction.List, foo), "#A4");

            Assert.AreEqual("/FooTable/List.aspx", m.GetActionPath("FooTable", "List", foo), "#B1");
        }