public void GetLabel_DummyLocalizedController_EnsuresTheResourceStringIsFound() { // Arrange var initializer = new DummyControllerContainerInitializer(); Type controller = typeof(DummyLocalizedController); var context = new ViewContext(); context.Controller = new DummyLocalizedController(); var urlHelper = new HtmlHelper(context, new DummyViewDataContainer()); using (new ObjectFactoryContainerRegion()) { ObjectFactory.Container.RegisterType<ConfigManager, ConfigManager>(typeof(XmlConfigProvider).Name.ToUpperInvariant(), new InjectionConstructor(typeof(XmlConfigProvider).Name)); ObjectFactory.Container.RegisterType<XmlConfigProvider, DummyConfigProvider>(); Config.RegisterSection<ResourcesConfig>(); Config.RegisterSection<ProjectConfig>(); // Act initializer.RegisterControllerPublic(controller); var resourceString = urlHelper.Resource("DummyResource"); // Assert var resourceRegistered = ObjectFactory.Container.IsRegistered(typeof(DummyLocalizationControllerResources), Res.GetResourceClassId(typeof(DummyLocalizationControllerResources))); Assert.IsTrue(resourceRegistered, "String resources were not registered for the controller."); Assert.IsFalse(resourceString.IsNullOrEmpty(), "The resource with the given key was not found"); Assert.AreEqual("Dummy Resource", resourceString, "The returned resource is not as expected"); } }
public void RegisterController_DummyController_IsRegisteredInStore() { // Arrange var initializer = new DummyControllerContainerInitializer(); Type controller = typeof(DummyController); using (new ObjectFactoryContainerRegion()) { ObjectFactory.Container.RegisterType<ConfigManager, ConfigManager>(typeof(XmlConfigProvider).Name.ToUpperInvariant(), new InjectionConstructor(typeof(XmlConfigProvider).Name)); ObjectFactory.Container.RegisterType<XmlConfigProvider, DummyConfigProvider>(); Config.RegisterSection<ResourcesConfig>(); Config.RegisterSection<ProjectConfig>(); // Act initializer.RegisterControllerPublic(controller); // Assert var resourceRegistered = ObjectFactory.Container.IsRegistered(typeof(DummyControllerResources), Res.GetResourceClassId(typeof(DummyControllerResources))); Assert.IsTrue(resourceRegistered, "String resources were not registered for the controller."); } ControllerInfo registration = ControllerStore.Controllers().SingleOrDefault(c => c.ControllerType == controller); Assert.IsNotNull(registration, "Controller was not registered."); var route = RouteTable.Routes[controller.Name]; Assert.IsNull(route, "Route was registered for the controller."); }
public void RegisterController_DesignerController_NotRegistersAnyRoutes() { // Arrange var initializer = new DummyControllerContainerInitializer(); Type controller = typeof(DesignerController); using (new ObjectFactoryContainerRegion()) { ObjectFactory.Container.RegisterType<ConfigManager, ConfigManager>(typeof(XmlConfigProvider).Name.ToUpperInvariant(), new InjectionConstructor(typeof(XmlConfigProvider).Name)); ObjectFactory.Container.RegisterType<XmlConfigProvider, DummyConfigProvider>(); // Act initializer.RegisterControllerPublic(controller); } // Assert ControllerInfo registration = ControllerStore.Controllers().SingleOrDefault(c => c.ControllerType == controller); Assert.IsNotNull(registration, "DesignerController was not registered."); RouteBase route = RouteTable.Routes[controller.Name]; Assert.IsNull(route, "Route was registered for the controller."); }