public void GetQuery_Context() { MetaModel m = Utils.GetModel <MyDataContext2> (); var req = new FakeHttpWorkerRequest(); var ctx = new HttpContext(req); HttpContext.Current = ctx; RouteCollection routes = RouteTable.Routes; routes.Clear(); var route = new MyDynamicDataRoute("{table}/{action}.aspx") { Constraints = new RouteValueDictionary(new { action = "List|Details|Edit|Insert" }), Model = m, RouteHandler = new MyDynamicDataRouteHandler() }; routes.Add(route); MetaTable t = m.GetTable("FooTable");; IQueryable query = t.GetQuery(null); Assert.IsNotNull(query, "#A1"); Assert.IsTrue(query.GetType() == typeof(Table <Foo>), "#A2"); var foo = new Foo(true); AssertExtensions.Throws(() => t.GetQuery(foo), "#B1"); }
public void GetQuery_Context () { MetaModel m = Utils.GetModel<MyDataContext2> (); var req = new FakeHttpWorkerRequest (); var ctx = new HttpContext (req); HttpContext.Current = ctx; RouteCollection routes = RouteTable.Routes; routes.Clear (); var route = new MyDynamicDataRoute ("{table}/{action}.aspx") { Constraints = new RouteValueDictionary (new { action = "List|Details|Edit|Insert" }), Model = m, RouteHandler = new MyDynamicDataRouteHandler () }; routes.Add (route); MetaTable t = m.GetTable ("FooTable"); ; IQueryable query = t.GetQuery (null); Assert.IsNotNull (query, "#A1"); Assert.IsTrue (query.GetType () == typeof (Table<Foo>), "#A2"); var foo = new Foo (true); AssertExtensions.Throws (() => t.GetQuery (foo), "#B1"); }