public AddController ( String areaName, String controllerName, |
||
areaName | String | The area name, or |
controllerName | String | The controller name |
controller | The controller representation | |
return | void |
public void EmptyArea() { DefaultControllerTree tree = new DefaultControllerTree(); tree.AddController("", "home", typeof(HomeController)); tree.AddController("", "contact", typeof(ContactController)); tree.AddController("", "cart", typeof(CartController)); Assert.AreEqual( typeof(HomeController), tree.GetController("", "home") ); Assert.AreEqual( typeof(ContactController), tree.GetController("", "contact") ); Assert.AreEqual( typeof(CartController), tree.GetController("", "cart") ); }
public void AddingController_RaisesNotifcationEvent() { DefaultControllerTree tree = new DefaultControllerTree(); bool eventRaised = false; tree.ControllerAdded += delegate { eventRaised = true; }; tree.AddController("clients","home",typeof(ClientHomeController)); Assert.IsTrue(eventRaised); }
public void Should_AddTwoUrls_WhenControllerAddedToTree() { MockRepository mocks = new MockRepository(); IUrlTokenizer tokenizer = mocks.DynamicMock<IUrlTokenizer>(); IControllerTree controllerTree = new DefaultControllerTree(); StubServiceProvider serviceProvider = new StubServiceProvider(tokenizer, controllerTree); DefaultUrlProvider provider = new DefaultUrlProvider(); provider.Service(serviceProvider); using (mocks.Record()) { tokenizer.AddDefaultRule("area/controller.rails", "area", "controller", "collection"); tokenizer.AddDefaultRule("/area/controller.rails", "area","controller", "collection"); } using (mocks.Playback()) { controllerTree.AddController("area", "controller", typeof(SampleRestController)); } }
public void FewAreas() { DefaultControllerTree tree = new DefaultControllerTree(); tree.AddController("", "home", typeof(HomeController)); tree.AddController("", "contact", typeof(ContactController)); tree.AddController("", "cart", typeof(CartController)); tree.AddController("clients", "home", typeof(ClientHomeController)); tree.AddController("clients", "contact", typeof(ClientContactController)); tree.AddController("clients", "cart", typeof(ClientCartController)); tree.AddController("lists", "home", typeof(ListController)); Assert.AreEqual( typeof(HomeController), tree.GetController("", "home") ); Assert.AreEqual( typeof(ContactController), tree.GetController("", "contact") ); Assert.AreEqual( typeof(CartController), tree.GetController("", "cart") ); Assert.AreEqual( typeof(ClientHomeController), tree.GetController("clients", "home") ); Assert.AreEqual( typeof(ClientContactController), tree.GetController("clients", "contact") ); Assert.AreEqual( typeof(ClientCartController), tree.GetController("clients", "cart") ); Assert.AreEqual( typeof(ListController), tree.GetController("lists", "home") ); }