Skip to content

Commit 043ba85

Browse files
committed
Update ShouldCreateFile test
1 parent fc6bf87 commit 043ba85

5 files changed

+152
-5
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by a tool.
4+
// GitVersion
5+
//
6+
// Changes to this file may cause incorrect behavior and will be lost if
7+
// the code is regenerated.
8+
// </auto-generated>
9+
//------------------------------------------------------------------------------
10+
11+
[global::System.Runtime.CompilerServices.CompilerGenerated]
12+
static class GitVersionInformation
13+
{
14+
public static string Major = "1";
15+
public static string Minor = "2";
16+
public static string Patch = "3";
17+
public static string PreReleaseTag = "unstable.4";
18+
public static string PreReleaseTagWithDash = "-unstable.4";
19+
public static string PreReleaseLabel = "unstable";
20+
public static string PreReleaseNumber = "4";
21+
public static string BuildMetaData = "5";
22+
public static string BuildMetaDataPadded = "0005";
23+
public static string FullBuildMetaData = "5.Branch.feature1.Sha.commitSha";
24+
public static string MajorMinorPatch = "1.2.3";
25+
public static string SemVer = "1.2.3-unstable.4";
26+
public static string LegacySemVer = "1.2.3-unstable4";
27+
public static string LegacySemVerPadded = "1.2.3-unstable0004";
28+
public static string AssemblySemVer = "1.2.3.0";
29+
public static string AssemblySemFileVer = "1.2.3.0";
30+
public static string FullSemVer = "1.2.3-unstable.4+5";
31+
public static string InformationalVersion = "1.2.3-unstable.4+5.Branch.feature1.Sha.commitSha";
32+
public static string BranchName = "feature1";
33+
public static string Sha = "commitSha";
34+
public static string NuGetVersionV2 = "1.2.3-unstable0004";
35+
public static string NuGetVersion = "1.2.3-unstable0004";
36+
public static string NuGetPreReleaseTagV2 = "unstable0004";
37+
public static string NuGetPreReleaseTag = "unstable0004";
38+
public static string CommitsSinceVersionSource = "5";
39+
public static string CommitsSinceVersionSourcePadded = "0005";
40+
public static string CommitDate = "2014-03-06";
41+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by a tool.
4+
// GitVersion
5+
//
6+
// Changes to this file may cause incorrect behavior and will be lost if
7+
// the code is regenerated.
8+
// </auto-generated>
9+
//------------------------------------------------------------------------------
10+
11+
[<AbstractClass; Sealed>]
12+
[<global.System.Runtime.CompilerServices.CompilerGenerated>]
13+
module GitVersionInformation =
14+
let Major = "1"
15+
let Minor = "2"
16+
let Patch = "3"
17+
let PreReleaseTag = "unstable.4"
18+
let PreReleaseTagWithDash = "-unstable.4"
19+
let PreReleaseLabel = "unstable"
20+
let PreReleaseNumber = "4"
21+
let BuildMetaData = "5"
22+
let BuildMetaDataPadded = "0005"
23+
let FullBuildMetaData = "5.Branch.feature1.Sha.commitSha"
24+
let MajorMinorPatch = "1.2.3"
25+
let SemVer = "1.2.3-unstable.4"
26+
let LegacySemVer = "1.2.3-unstable4"
27+
let LegacySemVerPadded = "1.2.3-unstable0004"
28+
let AssemblySemVer = "1.2.3.0"
29+
let AssemblySemFileVer = "1.2.3.0"
30+
let FullSemVer = "1.2.3-unstable.4+5"
31+
let InformationalVersion = "1.2.3-unstable.4+5.Branch.feature1.Sha.commitSha"
32+
let BranchName = "feature1"
33+
let Sha = "commitSha"
34+
let NuGetVersionV2 = "1.2.3-unstable0004"
35+
let NuGetVersion = "1.2.3-unstable0004"
36+
let NuGetPreReleaseTagV2 = "unstable0004"
37+
let NuGetPreReleaseTag = "unstable0004"
38+
let CommitsSinceVersionSource = "5"
39+
let CommitsSinceVersionSourcePadded = "0005"
40+
let CommitDate = "2014-03-06"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
'------------------------------------------------------------------------------
2+
' <auto-generated>
3+
' This code was generated by a tool.
4+
' GitVersion
5+
'
6+
' Changes to this file may cause incorrect behavior and will be lost if
7+
' the code is regenerated.
8+
' </auto-generated>
9+
'------------------------------------------------------------------------------
10+
11+
<Global.System.Runtime.CompilerServices.CompilerGenerated()>
12+
NotInheritable Class GitVersionInformation
13+
Private Sub New()
14+
End Sub
15+
Public Shared Major As String = "1"
16+
Public Shared Minor As String = "2"
17+
Public Shared Patch As String = "3"
18+
Public Shared PreReleaseTag As String = "unstable.4"
19+
Public Shared PreReleaseTagWithDash As String = "-unstable.4"
20+
Public Shared PreReleaseLabel As String = "unstable"
21+
Public Shared PreReleaseNumber As String = "4"
22+
Public Shared BuildMetaData As String = "5"
23+
Public Shared BuildMetaDataPadded As String = "0005"
24+
Public Shared FullBuildMetaData As String = "5.Branch.feature1.Sha.commitSha"
25+
Public Shared MajorMinorPatch As String = "1.2.3"
26+
Public Shared SemVer As String = "1.2.3-unstable.4"
27+
Public Shared LegacySemVer As String = "1.2.3-unstable4"
28+
Public Shared LegacySemVerPadded As String = "1.2.3-unstable0004"
29+
Public Shared AssemblySemVer As String = "1.2.3.0"
30+
Public Shared AssemblySemFileVer As String = "1.2.3.0"
31+
Public Shared FullSemVer As String = "1.2.3-unstable.4+5"
32+
Public Shared InformationalVersion As String = "1.2.3-unstable.4+5.Branch.feature1.Sha.commitSha"
33+
Public Shared BranchName As String = "feature1"
34+
Public Shared Sha As String = "commitSha"
35+
Public Shared NuGetVersionV2 As String = "1.2.3-unstable0004"
36+
Public Shared NuGetVersion As String = "1.2.3-unstable0004"
37+
Public Shared NuGetPreReleaseTagV2 As String = "unstable0004"
38+
Public Shared NuGetPreReleaseTag As String = "unstable0004"
39+
Public Shared CommitsSinceVersionSource As String = "5"
40+
Public Shared CommitsSinceVersionSourcePadded As String = "0005"
41+
Public Shared CommitDate As String = "2014-03-06"
42+
End Class

src/GitVersionCore.Tests/GitVersionCore.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,21 @@
177177
<Content Include="Approved\cs\AssemblyInfoFileUpdaterTests.ShouldCreateAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo.approved.txt" />
178178
<Content Include="Approved\cs\AssemblyInfoFileUpdaterTests.ShouldNotAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFileWhenVersionSchemeIsNone.approved.txt" />
179179
<Content Include="Approved\cs\AssemblyInfoFileUpdaterTests.ShouldNotReplaceAssemblyVersionWhenVersionSchemeIsNone.approved.txt" />
180+
<Content Include="Approved\cs\GitVersionInformationGeneratorTests.ShouldCreateFile.approved.txt" />
180181
<Content Include="Approved\fs\AssemblyInfoFileUpdaterTests.ShouldAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFile.approved.txt" />
181182
<Content Include="Approved\fs\AssemblyInfoFileUpdaterTests.ShouldCreateAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo.approved.txt" />
182183
<Content Include="Approved\fs\AssemblyInfoFileUpdaterTests.ShouldCreateAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInfo.approved.txt" />
183184
<Content Include="Approved\fs\AssemblyInfoFileUpdaterTests.ShouldCreateAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo.approved.txt" />
184185
<Content Include="Approved\fs\AssemblyInfoFileUpdaterTests.ShouldNotAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFileWhenVersionSchemeIsNone.approved.txt" />
185186
<Content Include="Approved\fs\AssemblyInfoFileUpdaterTests.ShouldNotReplaceAssemblyVersionWhenVersionSchemeIsNone.approved.txt" />
187+
<Content Include="Approved\fs\GitVersionInformationGeneratorTests.ShouldCreateFile.approved.txt" />
186188
<Content Include="Approved\vb\AssemblyInfoFileUpdaterTests.ShouldAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFile.approved.txt" />
187189
<Content Include="Approved\vb\AssemblyInfoFileUpdaterTests.ShouldCreateAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo.approved.txt" />
188190
<Content Include="Approved\vb\AssemblyInfoFileUpdaterTests.ShouldCreateAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInfo.approved.txt" />
189191
<Content Include="Approved\vb\AssemblyInfoFileUpdaterTests.ShouldCreateAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo.approved.txt" />
190192
<Content Include="Approved\vb\AssemblyInfoFileUpdaterTests.ShouldNotAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionFileWhenVersionSchemeIsNone.approved.txt" />
191193
<Content Include="Approved\vb\AssemblyInfoFileUpdaterTests.ShouldNotReplaceAssemblyVersionWhenVersionSchemeIsNone.approved.txt" />
194+
<Content Include="Approved\vb\GitVersionInformationGeneratorTests.ShouldCreateFile.approved.txt" />
192195
<Content Include="Approved\JsonVersionBuilderTests.Json.approved.txt" />
193196
<Content Include="Approved\VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForPreRelease.approved.txt" />
194197
<Content Include="Approved\VariableProviderTests.ProvidesVariablesInContinuousDeliveryModeForPreReleaseWithPadding.approved.txt" />

src/GitVersionCore.Tests/GitVersionInformationGeneratorTests.cs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,47 @@
66
using System.Threading.Tasks;
77
using GitVersion;
88
using NUnit.Framework;
9+
using Shouldly;
910

1011
namespace GitVersionCore.Tests
1112
{
1213
[TestFixture]
1314
public class GitVersionInformationGeneratorTests
1415
{
15-
[Test]
16-
public void ShouldCreateFile()
16+
[SetUp]
17+
public void SetLoggers()
18+
{
19+
ShouldlyConfiguration.ShouldMatchApprovedDefaults.LocateTestMethodUsingAttribute<TestCaseAttribute>();
20+
}
21+
22+
[TestCase("cs")]
23+
[TestCase("fs")]
24+
[TestCase("vb")]
25+
[Category("NoMono")]
26+
[Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")]
27+
public void ShouldCreateFile(string fileExtension)
1728
{
1829
var fileSystem = new TestFileSystem();
1930
var directory = Path.GetTempPath();
20-
var fileName = "GitVersionInformation.g.cs";
31+
var fileName = "GitVersionInformation.g." + fileExtension;
2132
var fullPath = Path.Combine(directory, fileName);
22-
var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);
2333

34+
var semanticVersion = new SemanticVersion
35+
{
36+
Major = 1,
37+
Minor = 2,
38+
Patch = 3,
39+
PreReleaseTag = "unstable4",
40+
BuildMetaData = new SemanticVersionBuildMetaData(5,
41+
"feature1", "commitSha", DateTimeOffset.Parse("2014-03-06 23:59:59Z"))
42+
};
43+
44+
var variables = VariableProvider.GetVariablesFor(semanticVersion, new TestEffectiveConfiguration(), false);
2445
var generator = new GitVersionInformationGenerator(fileName, directory, variables, fileSystem);
2546

2647
generator.Generate();
2748

28-
var fileContents = fileSystem.ReadAllText(fullPath);
49+
fileSystem.ReadAllText(fullPath).ShouldMatchApproved(c => c.SubFolder(Path.Combine("Approved", fileExtension)));
2950
}
3051
}
3152
}

0 commit comments

Comments
 (0)