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 PluginFactory factory = new PluginFactory(); // Act factory.CopyAssemblies(sourceDir, destDir); // Assert string fileContent = File.ReadAllText(pluginDestPath); Assert.That(fileContent, Is.EqualTo("file has been updated")); }
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 PluginFactory factory = new PluginFactory(); // Act factory.CopyAssemblies(sourceDir, destDir); // Assert string fileContent = File.ReadAllText(pluginDestPath); Assert.That(fileContent, Is.EqualTo("dest file is more recent")); }
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); } PluginFactory factory = new PluginFactory(); // Act factory.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); }