public void Test_Locate_Delete_User() { ControllerStateCollection strategies = new ControllerStateCollection(); strategies.Add(new ControllerInfo(typeof(CreateController))); strategies.Add(new ControllerInfo(typeof(MockController))); ControllerLocator locator = new ControllerLocator(strategies); ControllerInfo controller = (ControllerInfo)locator.Locate("Mock", "TestUser"); Assert.IsNotNull(controller, "No controller found."); }
/// <summary> /// Retrieves the controller with the provided action and type. /// </summary> /// <param name="action">The action that the controller performs.</param> /// <param name="typeName">The type of entity involved in the controller</param> /// <returns>The controller matching the provided action and type.</returns> public ControllerInfo GetController(string action, string typeName) { ControllerLocator locator = new ControllerLocator(this); ControllerInfo foundController = locator.Locate(action, typeName); if (foundController == null) { throw new ControllerNotFoundException(action, typeName); } return(foundController); }
public void Test_LocateFromInterfaces_Immediate() { Type type = typeof(BaseUniqueEntity); string action = "Delete"; ControllerStateCollection strategies = new ControllerStateCollection(); strategies.Add(new ControllerInfo(typeof(CreateController))); strategies.Add(new ControllerInfo(typeof(DeleteController))); ControllerLocator locator = new ControllerLocator(strategies); ControllerInfo info = locator.LocateFromInterfaces(action,type); Assert.IsNotNull(info, "No controller info found."); }