示例#1
0
        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));
        }
示例#2
0
        /// <summary>
        /// Provides derivative classes with a possibility to
        /// perform startup tasks.
        /// </summary>
        protected override void StartService()
        {
            if (!m_Configuration.HasValueFor(CoreConfigurationKeys.PluginLocation))
            {
                return;
            }

            var pluginDirectories = m_Configuration.Value <List <string> >(CoreConfigurationKeys.PluginLocation);

            foreach (var dir in pluginDirectories)
            {
                m_Detector.SearchDirectory(dir);
            }
        }
示例#3
0
        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);
        }