private void OnApplicationExit(object sender, EventArgs e) { // Remove custom DNS settings. _dnsManager.SetDNS(); // Restore the original file before exiting. _fileUpdater.RestoreTargetFile(_appSetting.HostFilePath); }
public void FileUpdateUnitTests_RestoreTargetFile() { string testFile = DirtyHostFilePath + ".test"; File.Copy(DirtyHostFilePath, testFile); bool result = _fileUpdater.RestoreTargetFile(testFile); var content = File.ReadAllText(testFile); Assert.IsTrue(result); Assert.IsTrue(!content.Contains("hostname6")); // Clean up. File.Delete(testFile); }