public void Should_be_able_to_set_nuget_dependency_versions_using_defaults() { var task = new SetNugetPackageVersions { BuildEngine = new Mock <IBuildEngine>().Object, ProjectFile = new TaskItem(FilePathExtensions.BasePath(@".\files\packages.csproj")), Files = new List <ITaskItem> { new TaskItem(FilePathExtensions.BasePath(@".\files\set-nuget-depencency-versions-default-test.txt")) }.ToArray() }; File.Copy(FilePathExtensions.BasePath(@".\files\set-nuget-depencency-versions-default.txt"), FilePathExtensions.BasePath(@".\files\set-nuget-depencency-versions-default-test.txt"), true); Assert.True(task.Execute()); var contents = File.ReadAllText(FilePathExtensions.BasePath(@".\files\set-nuget-depencency-versions-default-test.txt")); Assert.IsTrue(contents.Contains("<dependency id=\"another.package\" version=\"[3.2.1]\" />")); Assert.IsTrue(contents.Contains("<dependency id=\"some-package\" version=\"[1.2.3]\" />")); Assert.IsTrue(contents.Contains("<dependency id=\"prerelease-package\" version=\"[4.5.6]\" />")); Assert.IsTrue(contents.Contains("<dependency id=\"full-version.package\" version=\"[4.5.6.7000]\" />")); File.Delete(FilePathExtensions.BasePath(@".\files\set-nuget-depencency-versions-default-test.txt")); }
public void Should_be_able_to_find_and_replace_text() { var task = new RegexFindAndReplace { BuildEngine = new Mock <IBuildEngine>().Object, Files = new List <ITaskItem> { new TaskItem(FilePathExtensions.BasePath(@".\files\regex-find-and-replace-test.txt")) }.ToArray() }; File.Copy(FilePathExtensions.BasePath(@".\files\regex-find-and-replace.txt"), FilePathExtensions.BasePath(@".\files\regex-find-and-replace-test.txt"), true); task.FindExpression = @"AssemblyInformationalVersion\s*\(\s*"".*""\s*\)"; task.ReplacementText = "AssemblyInformationalVersion(\"new-version-number\")"; Assert.True(task.Execute()); task.FindExpression = @"AssemblyVersion\s*\(\s*"".*""\s*\)"; task.ReplacementText = "AssemblyVersion(\"new-version-number\")"; Assert.True(task.Execute()); task.FindExpression = @"\{semver\}"; task.ReplacementText = "new-version-number"; Assert.True(task.Execute()); var contents = File.ReadAllText(FilePathExtensions.BasePath(@".\files\regex-find-and-replace-test.txt")); Assert.IsTrue(contents.Contains("[assembly: AssemblyVersion(\"new-version-number\")]")); Assert.IsTrue(contents.Contains("[assembly: AssemblyInformationalVersion(\"new-version-number\")]")); Assert.IsTrue(contents.Contains("<version>new-version-number</version>")); File.Delete(FilePathExtensions.BasePath(@".\files\regex-find-and-replace-test.txt")); }