public void DefaultInitialisesActionsHandlers() { ActionHandlerFactory.Reset(); ActionHandlerFactory.PluginFolder = null; Assert.That( ActionHandlerFactory.Default.ActionHandlers, Is.Not.Empty); }
private static Lazy <ActionHandler, IActionHandlerMetadata> InitialiseMockHandler(string actionName) { ActionHandlerFactory.Reset(); ActionHandlerFactory.Default = new ActionHandlerFactory(); var metadataMock = new Mock <IActionHandlerMetadata>(MockBehavior.Strict); metadataMock.Setup(metadata => metadata.Name).Returns(actionName); var expected = new Lazy <ActionHandler, IActionHandlerMetadata>(metadataMock.Object); return(expected); }
public void DefaultIgnoresNonExistantDirectory() { ActionHandlerFactory.Reset(); ActionHandlerFactory.PluginFolder = Path.Combine( Path.GetTempPath(), "CCNetTesting"); if (Directory.Exists(ActionHandlerFactory.PluginFolder)) { Directory.Delete(ActionHandlerFactory.PluginFolder, true); } Assert.That( ActionHandlerFactory.Default.ActionHandlers, Is.Not.Empty); }
public void RetrieveHandlerReturnsNullIfNotFound() { try { var expected = InitialiseMockHandler("testAction"); ActionHandlerFactory.Default.ActionHandlers.Add(expected); var controller = new DynamicController(); var actual = controller.RetrieveHandler("garbage"); Assert.That(actual, Is.Null); } finally { ActionHandlerFactory.Reset(); } }
public void RetrieveHandlerIgnoresCase() { var actionName = "testAction"; try { var expected = InitialiseMockHandler(actionName); ActionHandlerFactory.Default.ActionHandlers.Add(expected); var controller = new DynamicController(); var actual = controller.RetrieveHandler(actionName.ToUpperInvariant()); Assert.That(actual, Is.SameAs(expected)); } finally { ActionHandlerFactory.Reset(); } }