1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.MonoRail
.Framework
.Tests
18 using System
.Reflection
;
19 using Castle
.MonoRail
.Framework
.Services
;
20 using NUnit
.Framework
;
24 public class DefaultControllerFactoryTestCase
26 private readonly String extension
= "rails";
28 private DefaultControllerFactory factory
;
33 factory
= new DefaultControllerFactory();
34 factory
.Service(new TestServiceContainer());
35 factory
.Inspect(Assembly
.GetExecutingAssembly());
39 public void EmptyArea()
41 Controller controller
= factory
.CreateController(new UrlInfo("domain", "sub", "", "http://", 80, "", "", "home", "", extension
, null));
43 Assert
.IsNotNull(controller
);
44 Assert
.AreEqual("Castle.MonoRail.Framework.Tests.Controllers.HomeController",
45 controller
.GetType().FullName
);
49 public void OneLevelArea()
51 Controller controller
=
52 factory
.CreateController(new UrlInfo("domain", "sub", "", "http://", 80, "", "clients", "home", "", extension
, null));
54 Assert
.IsNotNull(controller
);
55 Assert
.AreEqual("Castle.MonoRail.Framework.Tests.Controllers.Clients.ClientHomeController",
56 controller
.GetType().FullName
);
58 controller
= factory
.CreateController(new UrlInfo("domain", "sub", "", "http://", 80, "", "clients", "hire-us", "", extension
, null));
60 Assert
.IsNotNull(controller
);
61 Assert
.AreEqual("Castle.MonoRail.Framework.Tests.Controllers.Clients.OtherController",
62 controller
.GetType().FullName
);
65 factory
.CreateController(new UrlInfo("domain", "sub", "", "http://", 80, "", "ourproducts", "shoppingcart", "", extension
, null));
67 Assert
.IsNotNull(controller
);
68 Assert
.AreEqual("Castle.MonoRail.Framework.Tests.Controllers.Products.CartController",
69 controller
.GetType().FullName
);
72 factory
.CreateController(new UrlInfo("domain", "sub", "", "http://", 80, "", "ourproducts", "lista", "", extension
, null));
74 Assert
.IsNotNull(controller
);
75 Assert
.AreEqual("Castle.MonoRail.Framework.Tests.Controllers.Products.ListController",
76 controller
.GetType().FullName
);