public void when_no_replacements_applied_then_does_not_write_file() { var file = @"..\..\packages.config"; var timestamp = File.GetLastWriteTimeUtc(file); var task = new RegexReplace { BuildEngine = engine, Files = new ITaskItem[] { new TaskItem(file) }, Pattern = "/* LICENSE */", Replacement = "LICENSE" }; var result = task.Execute(); Assert.True(result); Assert.Equal(timestamp, File.GetLastWriteTimeUtc(file)); }
public void when_replacements_applied_then_writes_file_in_place() { var file = @"Sample.txt"; var original = File.ReadAllText(file); var task = new RegexReplace { BuildEngine = engine, Files = new ITaskItem[] { new TaskItem(file) }, Pattern = @"/\* LICENSE \*/", Replacement = "LICENSE" }; var result = task.Execute(); var actual = File.ReadAllText(file); Assert.NotEqual(original, actual); Assert.True(actual.StartsWith("LICENSE")); }