public void DirectoryLoader_ShouldThrowException_IfDirectoryIsInvalid() { //Given var loader = new DirectoryLoader <TestAppEvents>(string.Empty); var events = new TestAppEvents(); // When & Then Assert.Throws <ArgumentException>(() => loader.Load(events)); }
public void ModuleHost_ShouldLoad_ASingleModuleLoader() { // Given var loader = new Mock <ILoader <TestAppEvents> >(); var events = new TestAppEvents(); // When var moduleHost = new ModuleHost <TestAppEvents>(loader.Object, events); // Then loader.Verify(m => m.Load(events)); }
public void DirectoryLoader_ShouldBindEvents_IfDirectoryIsValid() { //Given var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "Test.Modules", "Path1"); var loader = new DirectoryLoader <TestAppEvents>(path); var events = new TestAppEvents(); //When var modules = loader.Load(events); //Then Assert.NotNull(events.MyEvent); }
public void DirectoryLoader_ShouldLoadModules_IfModuleFilterIsValid() { //Given var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "Test.Modules", "Path3"); var loader = new DirectoryLoader <TestAppEvents>(path, moduleFilter: "*.mod"); var events = new TestAppEvents(); //When var modules = loader.Load(events); //Then Assert.True(modules.Any()); }
public void DirectoryLoader_ShouldLoadSubDirectories_IfRecurseiveIsSet() { //Given var path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName; var loader = new DirectoryLoader <TestAppEvents>(path, true); var events = new TestAppEvents(); //When var modules = loader.Load(events); //Then Assert.True(modules.Any()); }
public void DirectoryLoader_ShouldLoadAllModules_IfMultipleDirectoriesAreProvided() { //Given var path1 = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "Test.Modules", "Path1"); var path2 = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "Test.Modules", "Path2"); var loader = new DirectoryLoader <TestAppEvents>(new string[] { path1, path2 }); var events = new TestAppEvents(); //When var modules = loader.Load(events); //Then Assert.Equal(2, modules.Count()); }
public void TypeLoader_ShouldNotBindEvents_WhenNoValidTypeNamesAreProvided() { // Given var types = new string[] { }; var loader = new TypeLoader <TestAppEvents>(types); var events = new TestAppEvents(); // When var modules = loader.Load(events); //Then Assert.Null(events.MyEvent); }
public void TypeLoader_ShouldBindEvents_WhenValidTypeNameIsProvided() { // Given var types = new string[] { "Test.Extensible.Module.TestModule, Test.Extensible.Module" }; var loader = new TypeLoader <TestAppEvents>(types); var events = new TestAppEvents(); // When var modules = loader.Load(events); //Then Assert.NotNull(events.MyEvent); }
public void ModuleHost_ShouldLoad_MultipleModuleLoaders() { // Given var loader1 = new Mock <ILoader <TestAppEvents> >(); var loader2 = new Mock <ILoader <TestAppEvents> >(); var loaders = new List <ILoader <TestAppEvents> >() { loader1.Object, loader2.Object }; var events = new TestAppEvents(); // When var moduleHost = new ModuleHost <TestAppEvents>(loaders, events); // Then loader1.Verify(m => m.Load(events)); loader2.Verify(m => m.Load(events)); }