public void EvaluateExpression ()
		{
			RouteTable.Routes.Clear ();
			RouteTable.Routes.Add (new Route ("{foo}-foo", new PageRouteHandler ("~/default.aspx")));
			RouteTable.Routes.Add ("bar1", new Route ("{bar}-foo", new PageRouteHandler ("~/bar.aspx")));
			RouteTable.Routes.Add ("bar2", new Route ("some-{bar}", new PageRouteHandler ("~/some-bar.aspx")));

			var bldr = new RouteUrlExpressionBuilder ();
			var entry = CreatePropertyEntry ("foo=test", "RouteUrl");
			var context = new ExpressionBuilderContext (new FakePage ());
			object obj = bldr.EvaluateExpression (null, entry, null, context);
			Assert.AreEqual ("/test-foo", obj, "#A1");

			entry = CreatePropertyEntry ("bar=test", "RouteUrl");
			obj = bldr.EvaluateExpression (null, entry, null, context);
			Assert.AreEqual ("/test-foo", obj, "#A2-1");

			entry = CreatePropertyEntry ("bar=test,routename=bar2", "RouteUrl");
			obj = bldr.EvaluateExpression (null, entry, null, context);
			Assert.AreEqual ("/some-test", obj, "#A2-2");

			entry = CreatePropertyEntry ("bar=test,routename=bar1", "RouteUrl");
			obj = bldr.EvaluateExpression (null, entry, null, context);
			Assert.AreEqual ("/test-foo", obj, "#A2-3");

			entry = CreatePropertyEntry ("bar=test,routename=noroute", "RouteUrl");
			try {
				obj = bldr.EvaluateExpression (null, entry, null, context);
				Assert.Fail ("#A3");
			} catch (ArgumentException) {
				// success
			}

			entry = CreatePropertyEntry ("nosuchparam=test", "RouteUrl");
			obj = bldr.EvaluateExpression (null, entry, null, context);
			Assert.IsNull (obj, "#A4");

			AssertExtensions.Throws<NullReferenceException> (() => {
				bldr.EvaluateExpression (null, null, null, context);
			}, "#A5-1");

			AssertExtensions.Throws<NullReferenceException> (() => {
				bldr.EvaluateExpression (null, entry, null, null);
			}, "#A5-2");
		}
		public void GetCodeExpression ()
		{
			var bldr = new RouteUrlExpressionBuilder ();
			var entry = CreatePropertyEntry ("foo=test", "RouteUrl");
			var context = new ExpressionBuilderContext (new FakePage ());
			CodeExpression expr;

			AssertExtensions.Throws<NullReferenceException> (() => {
				expr = bldr.GetCodeExpression (null, "data", context);
			}, "#A1-1");

			expr = bldr.GetCodeExpression (entry, null, context);
			Assert.IsNotNull (expr, "#A2");

			expr = bldr.GetCodeExpression (entry, "data", null);
			Assert.IsNotNull (expr, "#A3");

			expr = bldr.GetCodeExpression (entry, null, null);
			Assert.IsNotNull (expr, "#A4-1");
			Assert.AreEqual (typeof (CodeMethodInvokeExpression), expr.GetType (), "#A4-2");

			var invoke = expr as CodeMethodInvokeExpression;
			Assert.AreEqual (typeof (CodeTypeReferenceExpression), invoke.Method.TargetObject.GetType (), "#A4-3");

			var tref = invoke.Method.TargetObject as CodeTypeReferenceExpression;
			Assert.AreEqual ("System.Web.Compilation.RouteUrlExpressionBuilder", tref.Type.BaseType, "#A4-4");
			Assert.AreEqual ("GetRouteUrl", invoke.Method.MethodName, "#A4-5");
			
			Assert.AreEqual (2, invoke.Parameters.Count, "#A5-1");
			Assert.AreEqual (typeof (CodeThisReferenceExpression), invoke.Parameters [0].GetType (), "#A5-2");
			Assert.AreEqual (typeof (CodePrimitiveExpression), invoke.Parameters [1].GetType (), "#A5-3");

			var pex = invoke.Parameters [1] as CodePrimitiveExpression;
			Assert.AreEqual ("foo=test", pex.Value, "#A5-4");
		}