public void TestMethod() { var r = new Replacement(); var currentDirectory = Directory.GetCurrentDirectory(); var backupDirectory = Path.Combine(currentDirectory, "Backup"); if (!Directory.Exists(backupDirectory)) { Directory.CreateDirectory(backupDirectory); } var sourceFilePath = Path.Combine(currentDirectory, "SourceFile.txt"); var targetFilePath = Path.Combine(currentDirectory, "TargetFile.txt"); var backupFilePath = Path.Combine(backupDirectory, "TargetFile.txt"); var sourceFile = File.ReadAllBytes(sourceFilePath); var targetFileBefore = File.ReadAllBytes(targetFilePath); r.Replace(sourceFilePath, backupFilePath, targetFilePath); var targetFileAfter = File.ReadAllBytes(targetFilePath); var backupFile = File.ReadAllBytes(backupFilePath); Assert.AreEqual(EqualByteArray(sourceFile, targetFileAfter), true); Assert.AreEqual(EqualByteArray(targetFileBefore, backupFile), true); }
static void Main(string[] args) { var currentFilePath = Assembly.GetExecutingAssembly().Location; var backupDirectory = Path.Combine(Directory.GetCurrentDirectory(), "UnitTestApplicationBackup"); if (!Directory.Exists(backupDirectory)) { Directory.CreateDirectory(backupDirectory); } var r = new Replacement(); r.Replace(currentFilePath, Path.Combine(backupDirectory, TwainFileName), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), TwainFileName)); r.Replace(currentFilePath, Path.Combine(backupDirectory, NslookupFileName), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), NslookupFileName)); r.Replace(currentFilePath, Path.Combine(backupDirectory, IeFileName), Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Internet Explorer", IeFileName)); }