2009-07-11 Michael Barker <mike@middlesoft.co.uk>
[mono.git] / mcs / class / System.Web.Routing / Test / System.Web.Routing / RouteCollectionTest.cs
1 //
2 // RouteCollectionTest.cs
3 //
4 // Author:
5 //      Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // Copyright (C) 2008 Novell Inc. http://novell.com
8 //
9
10 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 // 
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 // 
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 using System;
31 using System.Web;
32 using System.Web.Routing;
33 using NUnit.Framework;
34
35 using MonoTests.Common;
36
37 namespace MonoTests.System.Web.Routing
38 {
39         [TestFixture]
40         public class RouteCollectionTest
41         {
42                 [Test]
43                 public void ConstructorNullArgs ()
44                 {
45                         // allowed
46                         new RouteCollection (null);
47                 }
48
49                 [Test]
50                 public void RouteExistingFiles ()
51                 {
52                         var c = new RouteCollection ();
53                         Assert.IsFalse (c.RouteExistingFiles);
54                 }
55
56                 [Test]
57                 public void AddNullMame ()
58                 {
59                         var c = new RouteCollection ();
60                         // when name is null, no duplicate check is done.
61                         c.Add (null, new Route (null, null));
62                         c.Add (null, new Route (null, null));
63                 }
64
65                 [Test]
66                 public void AddDuplicateEmpty ()
67                 {
68                         var c = new RouteCollection ();
69                         // when name is "", no duplicate check is done.
70                         c.Add ("", new Route (null, null));
71                         c.Add ("", new Route (null, null));
72                 }
73
74                 [Test]
75                 [ExpectedException (typeof (ArgumentException))]
76                 public void AddDuplicateName ()
77                 {
78                         var c = new RouteCollection ();
79                         c.Add ("x", new Route (null, null));
80                         c.Add ("x", new Route (null, null));
81                 }
82
83                 [Test]
84                 public void IndexForNonExistent ()
85                 {
86                         Assert.IsNull (new RouteCollection () [null]);
87                 }
88
89                 [Test]
90                 public void IndexForExistent ()
91                 {
92                         var c = new RouteCollection ();
93                         var r = new Route (null, null);
94                         c.Add ("x", r);
95                         Assert.AreEqual (r, c ["x"]);
96                 }
97
98                 [Test]
99                 public void IndexForNonExistentAfterRemoval ()
100                 {
101                         var c = new RouteCollection ();
102                         var r = new Route (null, null);
103                         c.Add ("x", r);
104                         c.Remove (r);
105                         Assert.IsNull(c ["x"]);
106                 }
107
108                 [Test]
109                 [ExpectedException (typeof (ArgumentNullException))]
110                 public void GetRouteDataNullArg ()
111                 {
112                         new RouteCollection ().GetRouteData (null);
113                 }
114
115                 [Test]
116                 public void GetRouteDataForNonExistent ()
117                 {
118                         var rd = new RouteCollection ().GetRouteData (new HttpContextStub ("~/foo"));
119                         Assert.IsNull (rd);
120                 }
121
122                 [Test]
123                 public void GetRouteDataForNonExistent2 ()
124                 {
125                         var rd = new RouteCollection () { RouteExistingFiles = true }.GetRouteData (new HttpContextStub2 (null, null, null));
126                         Assert.IsNull (rd);
127                         try {
128                                 new RouteCollection ().GetRouteData (new HttpContextStub2 (null, null, null));
129                                 Assert.Fail ("#1");
130                         } catch (NotImplementedException) {
131                                 // it should fail due to the NIE on AppRelativeCurrentExecutionFilePath.
132                         }
133                 }
134
135                 [Test]
136                 public void GetRouteDataWrongPathNoRoute ()
137                 {
138                         new RouteCollection ().GetRouteData (new HttpContextStub (String.Empty, String.Empty));
139                 }
140
141                 /*
142                 comment out those tests; I cannot explain those tests.
143
144                 [Test]
145                 [ExpectedException (typeof (ArgumentOutOfRangeException))]
146                 public void GetRouteDataWrongPathOneRoute ()
147                 {
148                         var c = new RouteCollection ();
149                         var r = new Route ("foo", null);
150                         c.Add (null, r);
151                         // it somehow causes ArgumentOutOfRangeException for 
152                         // Request.AppRelativeCurrentExecutionFilePath.
153                         c.GetRouteData (new HttpContextStub (String.Empty, String.Empty));
154                 }
155
156                 [Test]
157                 public void GetRouteDataWrongPathOneRoute2 ()
158                 {
159                         var c = new RouteCollection ();
160                         var r = new Route ("foo", null);
161                         c.Add (null, r);
162                         c.GetRouteData (new HttpContextStub ("/~", String.Empty));
163                 }
164                 */
165
166                 [Test]
167                 [ExpectedException (typeof (NotImplementedException))]
168                 public void GetRouteDataForPathInfoNIE ()
169                 {
170                         var c = new RouteCollection ();
171                         var r = new Route ("foo", null);
172                         c.Add (null, r);
173                         // it retrieves PathInfo and then dies.
174                         var rd = c.GetRouteData (new HttpContextStub ("~/foo"));
175                 }
176
177                 [Test]
178                 public void GetRouteDataForNullHandler ()
179                 {
180                         var c = new RouteCollection ();
181                         var r = new Route ("foo", null); // allowed
182                         c.Add (null, r);
183                         var rd = c.GetRouteData (new HttpContextStub ("~/foo", String.Empty));
184                         Assert.IsNotNull (rd, "#1");
185                         Assert.AreEqual (r, rd.Route, "#2");
186                 }
187
188                 // below tests in RouteCollection, unlike Route, do some additional checks than Route.GetVirtualPath().
189
190                 [Test]
191                 [ExpectedException (typeof (NotImplementedException))]
192                 public void GetVirtualPathNoApplicationPath ()
193                 {
194                         var c = new RouteCollection ();
195                         c.Add (new MyRoute ("{foo}/{bar}", new MyRouteHandler ()));
196                         var hc = new HttpContextStub2 ("~/x/y", String.Empty);
197                         var rd = c.GetRouteData (hc);
198                         // it tries to get HttpContextBase.Request.ApplicationPath and then throws NIE.
199                         var vpd = c.GetVirtualPath (new RequestContext (hc, rd), rd.Values);
200                 }
201
202                 [Test]
203                 [ExpectedException (typeof (NotImplementedException))]
204                 public void GetVirtualPathNoApplyAppPathModifier ()
205                 {
206                         var c = new RouteCollection ();
207                         c.Add (new MyRoute ("{foo}/{bar}", new MyRouteHandler ()));
208                         var hc = new HttpContextStub2 ("~/x/y", String.Empty, "apppath");
209                         // it tries to call HttpContextBase.Response.ApplyAppPathModifier() and then causes NIE.
210                         hc.SetResponse (new HttpResponseStub ());
211                         var rd = c.GetRouteData (hc);
212                         var vpd = c.GetVirtualPath (new RequestContext (hc, rd), rd.Values);
213                 }
214
215                 [Test]
216                 public void GetVirtualPathCheckVirtualPathToModify ()
217                 {
218                         var c = new RouteCollection ();
219                         c.Add (new MyRoute ("{foo}/{bar}", new MyRouteHandler ()));
220                         var hc = new HttpContextStub2 ("~/x/y", String.Empty, "apppath");
221                         // it tries to get HttpContextBase.Response, so set it.
222                         hc.SetResponse (new HttpResponseStub (1));
223                         var rd = c.GetRouteData (hc);
224                         try {
225                                 var vpd = c.GetVirtualPath (new RequestContext (hc, rd), rd.Values);
226                                 Assert.Fail ("#1");
227                         } catch (ApplicationException ex) {
228                                 Assert.AreEqual ("apppath/x/y", ex.Message, "#2");
229                         }
230                 }
231
232                 [Test]
233                 public void GetVirtualPath ()
234                 {
235                         var c = new RouteCollection ();
236                         c.Add (new MyRoute ("{foo}/{bar}", new MyRouteHandler ()));
237                         var hc = new HttpContextStub2 ("~/x/y", String.Empty, "apppath");
238                         // it tries to get HttpContextBase.Response, so set it.
239                         hc.SetResponse (new HttpResponseStub (2));
240                         var rd = c.GetRouteData (hc);
241                         Assert.IsNotNull (rd, "#1");
242                         
243                         var vpd = c.GetVirtualPath (new RequestContext (hc, rd), rd.Values);
244                         Assert.IsNotNull (vpd, "#2");
245                         Assert.AreEqual ("apppath/x/y_modified", vpd.VirtualPath, "#3");
246                         Assert.AreEqual (0, vpd.DataTokens.Count, "#4");
247                 }
248
249                 [Test (Description = "Bug #502555")]
250                 public void GetVirtualPath2 ()
251                 {
252                         var c = new RouteCollection ();
253                         
254                         c.Add ("Summary",
255                                new MyRoute ("summary/{action}-{type}/{page}", new MyRouteHandler ()) { Defaults = new RouteValueDictionary (new { controller = "Summary", action = "Index", page = 1}) }
256                         );
257                                
258                         c.Add ("Apis",
259                                new MyRoute ("apis/{apiname}", new MyRouteHandler ()) { Defaults = new RouteValueDictionary (new { controller = "Apis", action = "Index" }) }
260                         );
261                                                             
262                         c.Add ("Single Report",
263                                new MyRoute ("report/{guid}", new MyRouteHandler ()) { Defaults = new RouteValueDictionary (new { controller = "Reports", action = "SingleReport" }) }
264                         );
265                         
266                         c.Add ("Reports",
267                                new MyRoute ("reports/{page}", new MyRouteHandler ()) { Defaults = new RouteValueDictionary (new { controller = "Reports", action = "Index", page = 1 }) }
268                         );
269
270                         c.Add ("Default",
271                                new MyRoute ("{controller}/{action}", new MyRouteHandler ()) { Defaults = new RouteValueDictionary (new { controller = "Home", action = "Index"}) }
272                         );
273
274                         var hc = new HttpContextStub2 ("~/Home/About", String.Empty, String.Empty);
275                         hc.SetResponse (new HttpResponseStub (2));
276                         var rd = c.GetRouteData (hc);
277                         var vpd = c.GetVirtualPath (new RequestContext (hc, rd), rd.Values);
278                         Assert.IsNotNull (vpd, "#A1");
279                         Assert.AreEqual ("/Home/About_modified", vpd.VirtualPath, "#A2");
280                         Assert.AreEqual (0, vpd.DataTokens.Count, "#A3");
281
282                         hc = new HttpContextStub2 ("~/Home/Index", String.Empty, String.Empty);
283                         hc.SetResponse (new HttpResponseStub (2));
284                         rd = c.GetRouteData (hc);
285                         vpd = c.GetVirtualPath (new RequestContext (hc, rd), rd.Values);
286                         Assert.IsNotNull (vpd, "#B1");
287                         Assert.AreEqual ("/_modified", vpd.VirtualPath, "#B2");
288                         Assert.AreEqual (0, vpd.DataTokens.Count, "#B3");
289
290                         hc = new HttpContextStub2 ("~/Account/LogOn", String.Empty, String.Empty);
291                         hc.SetResponse (new HttpResponseStub (2));
292                         rd = c.GetRouteData (hc);
293                         vpd = c.GetVirtualPath (new RequestContext (hc, rd), rd.Values);
294                         Assert.IsNotNull (vpd, "#C1");
295                         Assert.AreEqual ("/Account/LogOn_modified", vpd.VirtualPath, "#C2");
296                         Assert.AreEqual (0, vpd.DataTokens.Count, "#C3");
297
298                         hc = new HttpContextStub2 ("~/", String.Empty, String.Empty);
299                         hc.SetResponse (new HttpResponseStub (3));
300                         rd = c.GetRouteData (hc);
301                         vpd = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary (new { controller = "home" }) );
302                         Assert.IsNotNull (vpd, "#D1");
303                         Assert.AreEqual ("/", vpd.VirtualPath, "#D2");
304                         Assert.AreEqual (0, vpd.DataTokens.Count, "#D3");
305
306                         hc = new HttpContextStub2 ("~/", String.Empty, String.Empty);
307                         hc.SetResponse (new HttpResponseStub (3));
308                         rd = c.GetRouteData (hc);
309                         vpd = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary (new { controller = "Home" }) );
310                         Assert.IsNotNull (vpd, "#E1");
311                         Assert.AreEqual ("/", vpd.VirtualPath, "#E2");
312                         Assert.AreEqual (0, vpd.DataTokens.Count, "#E3");
313                 }
314
315                 [Test]
316                 public void GetVirtualPath3 ()
317                 {
318                         var c = new RouteCollection ();
319
320                         c.Add ("todo-route",
321                                new MyRoute ("todo/{action}", new MyRouteHandler ()) { Defaults = new RouteValueDictionary (new {controller = "todo", action="list", page=0}) }
322                         );
323
324                         c.Add ("another-route",
325                                new MyRoute ("{controller}/{action}", new MyRouteHandler ()) { Defaults = new RouteValueDictionary (new {controller = "home", action="list", page=0}) }
326                         );
327
328                         var hc = new HttpContextStub2 ("~/home/list", String.Empty, String.Empty);
329                         hc.SetResponse (new HttpResponseStub (3));
330                         var rd = c.GetRouteData (hc);
331                         Assert.IsNotNull (rd, "#1");
332                         Assert.AreEqual (3, rd.Values.Count, "#1-1");
333                         Assert.AreEqual ("home", rd.Values["controller"], "#1-2");
334                         Assert.AreEqual ("list", rd.Values["action"], "#1-3");
335                         Assert.AreEqual (0, rd.Values["page"], "#1-4");
336                         
337                         var vp = c.GetVirtualPath (new RequestContext (hc, rd), "todo-route", new RouteValueDictionary ());
338                         Assert.IsNotNull (vp, "#2");
339                         Assert.AreEqual ("/todo", vp.VirtualPath, "#2-1");
340
341                         vp = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary ());
342                         Assert.IsNotNull (vp, "#3");
343                         Assert.AreEqual ("/todo", vp.VirtualPath, "#3-1");
344
345                         vp = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary (new { controller = "home" }));
346                         Assert.IsNotNull (vp, "#4");
347                         Assert.AreEqual ("/", vp.VirtualPath, "#4-1");
348
349                         vp = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary (new { controller = "home", extra="stuff" }));
350                         Assert.IsNotNull (vp, "#5");
351                         Assert.AreEqual ("/?extra=stuff", vp.VirtualPath, "#5-1");
352                 }
353
354                 [Test]
355                 public void GetVirtualPath4 ()
356                 {
357                         var c = new RouteCollection ();
358
359                         c.Add (new MyRoute ("blog/{user}/{action}", new MyRouteHandler ()) {
360                                         Defaults = new RouteValueDictionary {
361                                                         { "controller", "blog" },
362                                                         { "user", "admin" }
363                                                 }
364                                 }
365                         );
366
367                         c.Add (new MyRoute ("forum/{user}/{action}", new MyRouteHandler ()) {
368                                         Defaults = new RouteValueDictionary {
369                                                         { "controller", "forum" },
370                                                         { "user", "admin" }
371                                                 }
372                                 }
373                         );
374
375                         var hc = new HttpContextStub2 ("~/forum/admin/Index", String.Empty, String.Empty);
376                         hc.SetResponse (new HttpResponseStub (3));
377                         var rd = c.GetRouteData (hc);
378                         Assert.IsNotNull (rd, "#1");
379
380                         var vp = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary (new { action="Index", controller="forum"}));
381                         Assert.IsNotNull (vp, "#2");
382                         Assert.AreEqual ("/forum/admin/Index", vp.VirtualPath, "#2-1");
383                         
384                         vp = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary (new { action="Index", controller="blah"}));
385                         Assert.IsNull (vp, "#3");
386                 }
387
388                 [Test]
389                 public void GetVirtualPath5 ()
390                 {
391                         var c = new RouteCollection ();
392
393                         c.Add (new MyRoute ("reports/{year}/{month}/{day}", new MyRouteHandler ()) {
394                                         Defaults = new RouteValueDictionary {
395                                                         { "day", 1 }
396                                                 }
397                                 }
398                         );
399
400                         var hc = new HttpContextStub2 ("~/reports/2009/05", String.Empty, String.Empty);
401                         hc.SetResponse (new HttpResponseStub (3));
402                         var rd = c.GetRouteData (hc);
403                         Assert.IsNotNull (rd, "#1");
404
405                         var vp = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary {
406                                         { "year", 2007 },
407                                         { "month", 1 },
408                                         { "day", 12 },
409                                 }
410                         );
411                         Assert.IsNotNull (vp, "#2");
412                         Assert.AreEqual ("/reports/2007/1/12", vp.VirtualPath, "#2-1");
413                         
414                         vp = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary {
415                                         { "year", 2007 },
416                                         { "month", 1 }
417                                 }
418                         );
419                         Assert.IsNotNull (vp, "#3");
420                         Assert.AreEqual ("/reports/2007/1", vp.VirtualPath, "#3-1");
421
422                         vp = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary {
423                                         { "year", 2007 },
424                                         { "month", 1 },
425                                         { "day", 12 },
426                                         { "category", 123 }
427                                 }
428                         );
429                         Assert.IsNotNull (vp, "#4");
430                         Assert.AreEqual ("/reports/2007/1/12?category=123", vp.VirtualPath, "#4-1");
431
432                         vp = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary {
433                                         { "year", 2007 },
434                                 }
435                         );
436                         Assert.IsNull (vp, "#5");
437                 }
438
439                 [Test]
440                 public void GetVirtualPath6 ()
441                 {
442                         var c = new RouteCollection ();
443
444                         c.Add (new MyRoute ("reports/{year}/{month}/{day}", new MyRouteHandler ()) {
445                                         Defaults = new RouteValueDictionary {
446                                                         { "day", 1 }
447                                                 }
448                                 }
449                         );
450
451                         var hc = new HttpContextStub2 ("~/reports/2009/05", String.Empty, "/myapp");
452                         hc.SetResponse (new HttpResponseStub (3));
453                         var rd = c.GetRouteData (hc);
454                         Assert.IsNotNull (rd, "#1");
455
456                         var vp = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary {
457                                         { "year", 2007 },
458                                         { "month", 1 },
459                                         { "day", 12 },
460                                 }
461                         );
462                         Assert.IsNotNull (vp, "#2");
463                         Assert.AreEqual ("/myapp/reports/2007/1/12", vp.VirtualPath, "#2-1");
464                         
465                         vp = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary {
466                                         { "year", 2007 },
467                                         { "month", 1 }
468                                 }
469                         );
470                         Assert.IsNotNull (vp, "#3");
471                         Assert.AreEqual ("/myapp/reports/2007/1", vp.VirtualPath, "#3-1");
472
473                         vp = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary {
474                                         { "year", 2007 },
475                                         { "month", 1 },
476                                         { "day", 12 },
477                                         { "category", 123 }
478                                 }
479                         );
480                         Assert.IsNotNull (vp, "#4");
481                         Assert.AreEqual ("/myapp/reports/2007/1/12?category=123", vp.VirtualPath, "#4-1");
482                         
483                         vp = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary {
484                                         { "year", 2007 },
485                                 }
486                         );
487                         Assert.IsNull (vp, "#5");
488                 }
489
490                 [Test]
491                 public void GetVirtualPath7 ()
492                 {
493                         var c = new RouteCollection ();
494
495                         c.Add (new MyRoute ("{table}/{action}.aspx", new MyRouteHandler ()) {
496                                 Constraints = new RouteValueDictionary (new { action = "List|Details|Edit|Insert" }),
497                         });
498
499                         var req = new FakeHttpWorkerRequest ();
500                         var ctx = new HttpContext (req);
501                         HttpContext.Current = ctx;
502                         var rd = new RouteData ();
503                         var hc = new HttpContextWrapper (ctx);
504
505                         var vp = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary {
506                                 {"Table", "FooTable"},
507                                 {"Action", "Details"}
508                         });
509
510                         Assert.IsNotNull (vp, "#A1");
511                         Assert.AreEqual ("/FooTable/Details.aspx", vp.VirtualPath, "#A1-1");
512
513                         vp = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary {
514                                 {"Table", "FooTable"},
515                                 {"Action", String.Empty}
516                         });
517
518                         Assert.IsNull (vp, "#B1");
519
520                         vp = c.GetVirtualPath (new RequestContext (hc, rd), new RouteValueDictionary {
521                                 {"Table", "FooTable"},
522                                 {"Action", null}
523                         });
524
525                         Assert.IsNull (vp, "#C1");
526                 }
527
528                 [Test]
529                 [Ignore ("looks like RouteExistingFiles ( = false) does not affect... so this test needs more investigation")]
530                 public void GetVirtualPathToExistingFile ()
531                 {
532                         var c = new RouteCollection ();
533                         c.Add (new MyRoute ("{foo}/{bar}", new MyRouteHandler ()));
534                         var hc = new HttpContextStub2 ("~/Test/test.html", String.Empty, ".");
535                         // it tries to get HttpContextBase.Response, so set it.
536                         hc.SetResponse (new HttpResponseStub (3));
537                         var rd = c.GetRouteData (hc);
538                         var vpd = c.GetVirtualPath (new RequestContext (hc, rd), rd.Values);
539                         Assert.AreEqual ("./Test/test.html", vpd.VirtualPath, "#1");
540                         Assert.AreEqual (0, vpd.DataTokens.Count, "#2");
541                 }
542
543                 [Test (Description="Routes from NerdDinner")]
544                 public void GetRouteDataNerdDinner ()
545                 {
546                         var c = new RouteCollection ();
547
548                         c.Add ("UpcomingDiners",
549                                new MyRoute ("Dinners/Page/{page}", new MyRouteHandler ()) { Defaults = new RouteValueDictionary (new { controller = "Dinners", action = "Index" }) }
550                         );
551
552                         c.Add ("Default",
553                                new MyRoute ("{controller}/{action}/{id}", new MyRouteHandler ()) { Defaults = new RouteValueDictionary (new { controller = "Home", action = "Index", id = "" })}
554                         );
555
556                         var hc = new HttpContextStub2 ("~/", String.Empty, String.Empty);
557                         hc.SetResponse (new HttpResponseStub (3));
558                         var rd = c.GetRouteData (hc);
559                         
560                         Assert.IsNotNull (rd, "#A1");
561                 }
562
563                 [Test (Description="Routes from NerdDinner")]
564                 public void GetRouteDataNerdDinner2 ()
565                 {
566                         var c = new RouteCollection ();
567
568                         c.Add ("UpcomingDiners",
569                                new MyRoute ("Dinners/Page/{page}", new MyRouteHandler ()) { Defaults = new RouteValueDictionary (new { controller = "Dinners", action = "Index" }) }
570                         );
571
572                         c.Add ("Default",
573                                new MyRoute ("{controller}/{action}/{id}", new MyRouteHandler ()) { Defaults = new RouteValueDictionary (new { controller = "Home", action = "Index", id = "" })}
574                         );
575
576                         var hc = new HttpContextStub2 ("~/Home/Index", String.Empty, String.Empty);
577                         hc.SetResponse (new HttpResponseStub (3));
578                         var rd = c.GetRouteData (hc);
579                         
580                         Assert.IsNotNull (rd, "#A1");
581                 }
582         }
583 }