예제 #1
0
        public void copyassemblies_should_copy_source_dll_when_source_is_more_recent()
        {
            // Arrange
            string pluginId         = "PluginSourceMoreRecentTest";
            string sourceDir        = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins", "Text");
            string sourcePluginPath = Path.Combine(sourceDir, pluginId, "copytextplugintest.dll");

            CreatePluginFile(sourceDir, pluginId);

            string destDir        = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
            string pluginDestPath = Path.Combine(destDir, pluginId, "copytextplugintest.dll");

            CreatePluginFile(destDir, pluginId);

            Thread.Sleep(250);                                            // slow the test down slightly
            File.WriteAllText(sourcePluginPath, "file has been updated"); // update the source plugin

            // Act
            PluginFileManager.CopyAssemblies(sourceDir, destDir);

            // Assert
            string fileContent = File.ReadAllText(pluginDestPath);

            Assert.That(fileContent, Is.EqualTo("file has been updated"));
        }
예제 #2
0
        public void copyassemblies_should_not_copy_source_dll_when_destination_is_more_recent()
        {
            // Arrange
            string pluginId  = "PluginDestMoreRecentTest";
            string sourceDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins", "Text");

            CreatePluginFile(sourceDir, pluginId);

            string destDir          = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
            string pluginDestFolder = Path.Combine(destDir, pluginId);
            string pluginDestPath   = Path.Combine(pluginDestFolder, "copytextplugintest.dll");

            if (!Directory.Exists(pluginDestFolder))
            {
                Directory.CreateDirectory(pluginDestFolder);
            }
            File.WriteAllText(pluginDestPath, "dest file is more recent");              // create the plugin in the destination path so it's more recent

            // Act
            PluginFileManager.CopyAssemblies(sourceDir, destDir);

            // Assert
            string fileContent = File.ReadAllText(pluginDestPath);

            Assert.That(fileContent, Is.EqualTo("dest file is more recent"));
        }
예제 #3
0
        public void copyassemblies_should_copy_all_dlls_to_pluginsbinpath()
        {
            // Arrange
            string sourceDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins", "Text");

            CreatePluginFile(sourceDir, "Plugin1");
            CreatePluginFile(sourceDir, "Plugin2");
            CreatePluginFile(sourceDir, "Plugin3");

            string destDir     = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
            string plugin1Path = Path.Combine(destDir, "Plugin1", "copytextplugintest.dll");
            string plugin2Path = Path.Combine(destDir, "Plugin2", "copytextplugintest.dll");
            string plugin3Path = Path.Combine(destDir, "Plugin3", "copytextplugintest.dll");

            if (File.Exists(plugin1Path))
            {
                File.Delete(plugin1Path);
            }

            if (File.Exists(plugin2Path))
            {
                File.Delete(plugin2Path);
            }

            if (File.Exists(plugin3Path))
            {
                File.Delete(plugin3Path);
            }

            // Act
            PluginFileManager.CopyAssemblies(sourceDir, destDir);

            // Assert
            Assert.That(File.Exists(plugin1Path), Is.True);
            Assert.That(File.Exists(plugin2Path), Is.True);
            Assert.That(File.Exists(plugin3Path), Is.True);
        }