public void CanSetNextVersion() { var testFileSystem = new TestFileSystem(); var testConsole = new TestConsole("3", "2.0.0", "0"); ConfigurationProvider.Init("c:\\proj", testFileSystem, testConsole); testFileSystem.ReadAllText("c:\\proj\\GitVersionConfig.yaml").ShouldMatchApproved(); }
public void ShouldCreateCSharpAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo() { var fileSystem = new TestFileSystem(); const string workingDir = "C:\\Testing"; ISet<string> assemblyInfoFile = new HashSet<string> { @"src\Project\Properties\VersionAssemblyInfo.cs" }; var fullPath = Path.Combine(workingDir, assemblyInfoFile.First()); var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); using (new AssemblyInfoFileUpdate(new Arguments { EnsureAssemblyInfo = true, UpdateAssemblyInfo = true, UpdateAssemblyInfoFileName = assemblyInfoFile }, workingDir, variables, fileSystem)) { fileSystem.ReadAllText(fullPath).ShouldMatchApproved(); } }
public void ShouldCreateAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo(string fileExtension) { var fileSystem = new TestFileSystem(); var workingDir = Path.GetTempPath(); var assemblyInfoFile = Path.Combine("src", "Project", "Properties", "VersionAssemblyInfo." + fileExtension); var fullPath = Path.Combine(workingDir, assemblyInfoFile); var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, true)) { assemblyInfoFileUpdater.Update(); fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); } }
public void ShouldCreateCSharpAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo() { var fileSystem = new TestFileSystem(); var workingDir = Path.GetTempPath(); ISet <string> assemblyInfoFile = new HashSet <string> { Path.Combine("src", "Project", "Properties", "VersionAssemblyInfo.cs") }; var fullPath = Path.Combine(workingDir, assemblyInfoFile.First()); var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); using (new AssemblyInfoFileUpdate(new Arguments { EnsureAssemblyInfo = true, UpdateAssemblyInfo = true, UpdateAssemblyInfoFileName = assemblyInfoFile }, workingDir, variables, fileSystem)) { fileSystem.ReadAllText(fullPath).ShouldMatchApproved(); } }
public void ShouldCreateAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo(string fileExtension) { var fileSystem = new TestFileSystem(); var workingDir = Path.GetTempPath(); var assemblyInfoFile = Path.Combine("src", "Project", "Properties", "VersionAssemblyInfo." + fileExtension); var fullPath = Path.Combine(workingDir, assemblyInfoFile); var version = SemanticVersion.Parse("1.0.0", "v"); var variables = version.ToVersionVariables(new TestEffectiveConfiguration()); using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, true)) { assemblyInfoFileUpdater.Update(); fileSystem.ReadAllText(fullPath) .ShouldMatchApproved(c => c .NoDiff() .WithDescriminator(fileExtension)); } }
public void ShouldCreateAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo(string fileExtension) { var fileSystem = new TestFileSystem(); var workingDir = Path.GetTempPath(); var assemblyInfoFile = new HashSet <string> { "VersionAssemblyInfo." + fileExtension }; var fullPath = Path.Combine(workingDir, assemblyInfoFile.First()); var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); var arguments = new Arguments { EnsureAssemblyInfo = true, UpdateAssemblyInfo = true, UpdateAssemblyInfoFileName = assemblyInfoFile }; using (new AssemblyInfoFileUpdate(arguments, workingDir, variables, fileSystem)) { fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); } }
public void ShouldCreateAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo(string fileExtension) { var fileSystem = new TestFileSystem(); var workingDir = Path.GetTempPath(); var assemblyInfoFile = new HashSet<string> { Path.Combine("src", "Project", "Properties", "VersionAssemblyInfo." + fileExtension) }; var fullPath = Path.Combine(workingDir, assemblyInfoFile.First()); var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); var arguments = new Arguments { EnsureAssemblyInfo = true, UpdateAssemblyInfo = true, UpdateAssemblyInfoFileName = assemblyInfoFile }; using (new AssemblyInfoFileUpdate(arguments, workingDir, variables, fileSystem)) { fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension))); } }
public void ShouldCreateCSharpAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInfo() { var fileSystem = new TestFileSystem(); var workingDir = Path.GetTempPath(); ISet <string> assemblyInfoFile = new HashSet <string> { "AssemblyInfo.cs", Path.Combine("src", "Project", "Properties", "VersionAssemblyInfo.cs") }; var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); using (new AssemblyInfoFileUpdate(new Arguments { EnsureAssemblyInfo = true, UpdateAssemblyInfo = true, UpdateAssemblyInfoFileName = assemblyInfoFile }, workingDir, variables, fileSystem)) { foreach (var item in assemblyInfoFile) { var fullPath = Path.Combine(workingDir, item); var fileDescriminator = item.Replace(Path.DirectorySeparatorChar.ToString(), string.Empty).Replace(".", string.Empty); fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.WithDescriminator(fileDescriminator)); } } }
public void ShouldCreateCSharpAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInfo() { var fileSystem = new TestFileSystem(); const string workingDir = "C:\\Testing"; ISet <string> assemblyInfoFile = new HashSet <string> { "AssemblyInfo.cs", @"src\Project\Properties\VersionAssemblyInfo.cs" }; var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); using (new AssemblyInfoFileUpdate(new Arguments { EnsureAssemblyInfo = true, UpdateAssemblyInfo = true, UpdateAssemblyInfoFileName = assemblyInfoFile }, workingDir, variables, fileSystem)) { foreach (var item in assemblyInfoFile) { var fullPath = Path.Combine(workingDir, item); // ReSharper disable once AccessToForEachVariableInClosure fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.WithDescriminator(item.Replace("\\", string.Empty).Replace(".", string.Empty))); } } }
public void ShouldReplaceAssemblyVersionWhenCreatingVisualBasicAssemblyVersionFileAndEnsureAssemblyInfo() { var fileSystem = new TestFileSystem(); var version = new SemanticVersion { BuildMetaData = new SemanticVersionBuildMetaData(3, "foo", "hash", DateTimeOffset.Now), Major = 2, Minor = 3, Patch = 1 }; var workingDir = Path.GetTempPath(); string assemblyInfoFile = Join(@"AssemblyVersion(""1.0.0.0"");", @"AssemblyInformationalVersion(""1.0.0.0"");", @"AssemblyFileVersion(""1.0.0.0"");"); var fileName = Path.Combine(workingDir, "AssemblyInfo.vb"); fileSystem.WriteAllText(fileName, assemblyInfoFile); var variable = VariableProvider.GetVariablesFor(version, new TestEffectiveConfiguration(), false); var args = new Arguments { EnsureAssemblyInfo = true, UpdateAssemblyInfo = true, UpdateAssemblyInfoFileName = new HashSet <string> { "AssemblyInfo.vb" } }; using (new AssemblyInfoFileUpdate(args, workingDir, variable, fileSystem)) { string expected = Join(@"AssemblyVersion(""2.3.1.0"");", @"AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash"");", @"AssemblyFileVersion(""2.3.1.0"");"); fileSystem.ReadAllText(fileName).ShouldBe(expected); } }
public void ShouldCreateCSharpAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInfo() { var fileSystem = new TestFileSystem(); const string workingDir = "C:\\Testing"; ISet<string> assemblyInfoFile = new HashSet<string> { "AssemblyInfo.cs", @"src\Project\Properties\VersionAssemblyInfo.cs" }; var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false); using (new AssemblyInfoFileUpdate(new Arguments { EnsureAssemblyInfo = true, UpdateAssemblyInfo = true, UpdateAssemblyInfoFileName = assemblyInfoFile }, workingDir, variables, fileSystem)) { foreach (var item in assemblyInfoFile) { var fullPath = Path.Combine(workingDir, item); // ReSharper disable once AccessToForEachVariableInClosure fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.WithDescriminator(item.Replace("\\", string.Empty).Replace(".", string.Empty))); } } }
public void ShouldReplaceAssemblyVersionWhenCreatingVisualBasicAssemblyVersionFileAndEnsureAssemblyInfo() { var fileSystem = new TestFileSystem(); var version = new SemanticVersion { BuildMetaData = new SemanticVersionBuildMetaData(3, "foo", "hash", DateTimeOffset.Now), Major = 2, Minor = 3, Patch = 1 }; const string workingDir = "C:\\Testing"; const string assemblyInfoFile = @"AssemblyVersion(""1.0.0.0""); AssemblyInformationalVersion(""1.0.0.0""); AssemblyFileVersion(""1.0.0.0"");"; fileSystem.WriteAllText("C:\\Testing\\AssemblyInfo.vb", assemblyInfoFile); var variable = VariableProvider.GetVariablesFor(version, new TestEffectiveConfiguration(), false); var args = new Arguments { EnsureAssemblyInfo = true, UpdateAssemblyInfo = true, UpdateAssemblyInfoFileName = new HashSet<string> { "AssemblyInfo.vb" } }; using (new AssemblyInfoFileUpdate(args, workingDir, variable, fileSystem)) { const string expected = @"AssemblyVersion(""2.3.1.0""); AssemblyInformationalVersion(""2.3.1+3.Branch.foo.Sha.hash""); AssemblyFileVersion(""2.3.1.0"");"; fileSystem.ReadAllText("C:\\Testing\\AssemblyInfo.vb").ShouldBe(expected); } }