public void SearchWithNewFilesOnly() { var repository = new Mock <IPluginRepository>(); { repository.Setup(r => r.KnownPluginFiles()) .Returns(Enumerable.Empty <PluginFileInfo>()); } var files = new List <string> { @"c:\temp\foobar.dll", @"c:\temp\foobar2.dll" }; var mockFile = new MockFile(files.ToDictionary(f => f, f => string.Empty)); var mockDirectory = new MockDirectory(files); var fileSystem = new Mock <IFileSystem>(); { fileSystem.Setup(f => f.File) .Returns(mockFile); fileSystem.Setup(f => f.Directory) .Returns(mockDirectory); } var scanner = new MockScanner(); Func <IPluginRepository, IAssemblyScanner> scannerBuilder = r => scanner; var detector = new PluginDetector( repository.Object, scannerBuilder, fileSystem.Object, new SystemDiagnostics((p, s) => { }, null)); detector.SearchDirectory(@"c:\temp"); Assert.That(scanner.FilesToScan, Is.EquivalentTo(files)); }
/// <summary> /// Initializes a new instance of the <see cref="PluginService"/> class. /// </summary> /// <param name="configuration">The object that stores the configuration for the current application.</param> /// <param name="detector">The object that detects the available plugins.</param> /// <param name="diagnostics">The object that provides the diagnostics methods for the application.</param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="configuration"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="detector"/> is <see langword="null" />. /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="diagnostics"/> is <see langword="null" />. /// </exception> public PluginService(IConfiguration configuration, PluginDetector detector, SystemDiagnostics diagnostics) : base(diagnostics) { { Lokad.Enforce.Argument(() => configuration); Lokad.Enforce.Argument(() => detector); } m_Configuration = configuration; m_Detector = detector; }
public void SearchWithDeletedFilesOnly() { var pluginFiles = new List <PluginFileInfo> { new PluginFileInfo(@"c:\temp\foobar.dll", DateTimeOffset.Now), new PluginFileInfo(@"c:\temp\foobar2.dll", DateTimeOffset.Now.AddHours(-2)), }; var repository = new Mock <IPluginRepository>(); { repository.Setup(r => r.KnownPluginFiles()) .Returns(pluginFiles); } var mockFile = new MockFile(new Dictionary <string, string>()); var mockDirectory = new MockDirectory(new List <string>()); var fileSystem = new Mock <IFileSystem>(); { fileSystem.Setup(f => f.File) .Returns(mockFile); fileSystem.Setup(f => f.Directory) .Returns(mockDirectory); } var scanner = new MockScanner(); Func <IPluginRepository, IAssemblyScanner> scannerBuilder = r => scanner; var detector = new PluginDetector( repository.Object, scannerBuilder, fileSystem.Object, new SystemDiagnostics((p, s) => { }, null)); detector.SearchDirectory(@"c:\temp"); Assert.IsNull(scanner.FilesToScan); }