Skip to content

Commit 1ffcc96

Browse files
committed
replace Logger with ILog
1 parent 499ba45 commit 1ffcc96

File tree

57 files changed

+409
-321
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+409
-321
lines changed

src/GitVersionCore.Tests/AssemblyInfoFileUpdaterTests.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@
99
using GitVersion.Extensions;
1010
using GitVersion.Extensions.VersionAssemblyInfoResources;
1111
using GitVersion.Common;
12+
using GitVersion.Log;
1213

1314
namespace GitVersionCore.Tests
1415
{
1516
[TestFixture]
1617
[Parallelizable(ParallelScope.None)]
1718
public class AssemblyInfoFileUpdaterTests : TestBase
1819
{
20+
private IVariableProvider variableProvider;
21+
1922
[SetUp]
2023
public void Setup()
2124
{
2225
ShouldlyConfiguration.ShouldMatchApprovedDefaults.LocateTestMethodUsingAttribute<TestCaseAttribute>();
26+
var log = new NullLog();
27+
variableProvider = new VariableProvider(log);
2328
}
2429

2530
[TestCase("cs")]
@@ -33,7 +38,7 @@ public void ShouldCreateAssemblyInfoFileWhenNotExistsAndEnsureAssemblyInfo(strin
3338
var workingDir = Path.GetTempPath();
3439
var assemblyInfoFile = "VersionAssemblyInfo." + fileExtension;
3540
var fullPath = Path.Combine(workingDir, assemblyInfoFile);
36-
var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);
41+
var variables = variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);
3742

3843
using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, true))
3944
{
@@ -54,7 +59,7 @@ public void ShouldCreateAssemblyInfoFileAtPathWhenNotExistsAndEnsureAssemblyInfo
5459
var workingDir = Path.GetTempPath();
5560
var assemblyInfoFile = Path.Combine("src", "Project", "Properties", "VersionAssemblyInfo." + fileExtension);
5661
var fullPath = Path.Combine(workingDir, assemblyInfoFile);
57-
var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);
62+
var variables = variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);
5863

5964
using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, true))
6065
{
@@ -78,7 +83,7 @@ public void ShouldCreateAssemblyInfoFilesAtPathWhenNotExistsAndEnsureAssemblyInf
7883
"AssemblyInfo." + fileExtension,
7984
Path.Combine("src", "Project", "Properties", "VersionAssemblyInfo." + fileExtension)
8085
};
81-
var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);
86+
var variables = variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);
8287

8388
using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFiles, workingDir, variables, fileSystem, true))
8489
{
@@ -101,7 +106,7 @@ public void ShouldNotCreateAssemblyInfoFileWhenNotExistsAndNotEnsureAssemblyInfo
101106
var workingDir = Path.GetTempPath();
102107
var assemblyInfoFile = "VersionAssemblyInfo." + fileExtension;
103108
var fullPath = Path.Combine(workingDir, assemblyInfoFile);
104-
var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);
109+
var variables = variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);
105110

106111
using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, false))
107112
{
@@ -118,7 +123,7 @@ public void ShouldNotCreateAssemblyInfoFileForUnknownSourceCodeAndEnsureAssembly
118123
var workingDir = Path.GetTempPath();
119124
var assemblyInfoFile = "VersionAssemblyInfo.js";
120125
var fullPath = Path.Combine(workingDir, assemblyInfoFile);
121-
var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);
126+
var variables = variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);
122127

123128
using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFile, workingDir, variables, fileSystem, true))
124129
{
@@ -134,7 +139,7 @@ public void ShouldStartSearchFromWorkingDirectory()
134139
var fileSystem = Substitute.For<IFileSystem>();
135140
var workingDir = Path.GetTempPath();
136141
var assemblyInfoFiles = new HashSet<string>();
137-
var variables = VariableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);
142+
var variables = variableProvider.GetVariablesFor(SemanticVersion.Parse("1.0.0", "v"), new TestEffectiveConfiguration(), false);
138143

139144
using (var assemblyInfoFileUpdater = new AssemblyInfoFileUpdater(assemblyInfoFiles, workingDir, variables, fileSystem, false))
140145
{
@@ -469,7 +474,7 @@ public void ShouldNotAddAssemblyInformationalVersionWhenUpdatingAssemblyVersionF
469474
});
470475
}
471476

472-
private static void VerifyAssemblyInfoFile(
477+
private void VerifyAssemblyInfoFile(
473478
string assemblyFileContent,
474479
string fileName,
475480
AssemblyVersioningScheme versioningScheme = AssemblyVersioningScheme.MajorMinorPatch,
@@ -493,7 +498,7 @@ private static void VerifyAssemblyInfoFile(
493498
});
494499

495500
var config = new TestEffectiveConfiguration(assemblyVersioningScheme: versioningScheme);
496-
var variables = VariableProvider.GetVariablesFor(version, config, false);
501+
var variables = variableProvider.GetVariablesFor(version, config, false);
497502

498503
verify?.Invoke(fileSystem, variables);
499504
}

src/GitVersionCore.Tests/BuildServers/BuildServerBaseTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ public class BuildServerBaseTests : TestBase
1515

1616
private IEnvironment environment;
1717
private ILog log;
18+
private IVariableProvider variableProvider;
1819

1920
[SetUp]
2021
public void SetUp()
2122
{
2223
environment = new TestEnvironment();
2324
log = new NullLog();
25+
variableProvider = new VariableProvider(log);
2426
}
2527

2628
[Test]
@@ -41,7 +43,7 @@ public void BuildNumberIsFullSemVer()
4143

4244
var config = new TestEffectiveConfiguration();
4345

44-
var variables = VariableProvider.GetVariablesFor(semanticVersion, config, false);
46+
var variables = variableProvider.GetVariablesFor(semanticVersion, config, false);
4547
new BuildServer(environment, log).WriteIntegration(writes.Add, variables);
4648

4749
writes[1].ShouldBe("1.2.3-beta.1+5");

src/GitVersionCore.Tests/BuildServers/CodeBuildTests.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,39 @@
88
using GitVersion.BuildServers;
99
using GitVersion.Common;
1010
using GitVersion.OutputVariables;
11+
using GitVersion.Log;
1112

1213
namespace GitVersionCore.Tests.BuildServers
1314
{
1415
[TestFixture]
1516
public sealed class CodeBuildTests : TestBase
1617
{
1718
private IEnvironment environment;
19+
private ILog log;
20+
private IVariableProvider variableProvider;
1821

1922
[SetUp]
2023
public void SetUp()
2124
{
25+
log = new NullLog();
26+
2227
environment = new TestEnvironment();
28+
variableProvider = new VariableProvider(log);
2329
}
2430

2531
[Test]
2632
public void CorrectlyIdentifiesCodeBuildPresence()
2733
{
2834
environment.SetEnvironmentVariable(CodeBuild.HeadRefEnvironmentName, "a value");
29-
var cb = new CodeBuild(environment);
35+
var cb = new CodeBuild(environment, log);
3036
cb.CanApplyToCurrentContext().ShouldBe(true);
3137
}
3238

3339
[Test]
3440
public void PicksUpBranchNameFromEnvironment()
3541
{
3642
environment.SetEnvironmentVariable(CodeBuild.HeadRefEnvironmentName, "refs/heads/master");
37-
var cb = new CodeBuild(environment);
43+
var cb = new CodeBuild(environment, log);
3844
cb.GetCurrentBranch(false).ShouldBe("refs/heads/master");
3945
}
4046

@@ -71,9 +77,9 @@ private void AssertVariablesAreWrittenToFile(string f)
7177

7278
var config = new TestEffectiveConfiguration();
7379

74-
var variables = VariableProvider.GetVariablesFor(semanticVersion, config, false);
80+
var variables = variableProvider.GetVariablesFor(semanticVersion, config, false);
7581

76-
var j = new CodeBuild(environment, f);
82+
var j = new CodeBuild(environment, log, f);
7783

7884
j.WriteIntegration(writes.Add, variables);
7985

src/GitVersionCore.Tests/BuildServers/GitLabCiMessageGenerationTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ public class GitLabCiMessageGenerationTests : TestBase
1717
{
1818
private IEnvironment environment;
1919
private ILog log;
20+
private IVariableProvider variableProvider;
2021

2122
[SetUp]
2223
public void SetUp()
2324
{
2425
environment = new TestEnvironment();
2526
log = new NullLog();
27+
variableProvider = new VariableProvider(log);
2628
}
2729

2830
[Test]
@@ -75,7 +77,7 @@ private void AssertVariablesAreWrittenToFile(string f)
7577

7678
var config = new TestEffectiveConfiguration();
7779

78-
var variables = VariableProvider.GetVariablesFor(semanticVersion, config, false);
80+
var variables = variableProvider.GetVariablesFor(semanticVersion, config, false);
7981

8082
var j = new GitLabCi(environment, log, f);
8183

src/GitVersionCore.Tests/BuildServers/JenkinsMessageGenerationTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ public class JenkinsMessageGenerationTests : TestBase
1717
{
1818
private IEnvironment environment;
1919
private ILog log;
20+
private IVariableProvider variableProvider;
2021

2122
[SetUp]
2223
public void SetUp()
2324
{
2425
environment = new TestEnvironment();
2526
log = new NullLog();
27+
variableProvider = new VariableProvider(log);
2628
}
2729

2830
[Test]
@@ -75,7 +77,7 @@ private void AssertVariablesAreWrittenToFile(string f)
7577

7678
var config = new TestEffectiveConfiguration();
7779

78-
var variables = VariableProvider.GetVariablesFor(semanticVersion, config, false);
80+
var variables = variableProvider.GetVariablesFor(semanticVersion, config, false);
7981

8082
var j = new Jenkins(environment, log, f);
8183

src/GitVersionCore.Tests/GitToolsTestingExtensions.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ public static VersionVariables GetVersion(this RepositoryFixtureBase fixture, Co
2525
configuration = new Config();
2626
ConfigurationProvider.ApplyDefaultsTo(configuration);
2727
}
28-
var gitVersionContext = new GitVersionContext(repository ?? fixture.Repository, new NullLog(), targetBranch, configuration, isForTrackedBranchOnly, commitId);
28+
29+
var log = new NullLog();
30+
var variableProvider = new VariableProvider(log);
31+
var gitVersionContext = new GitVersionContext(repository ?? fixture.Repository, log, targetBranch, configuration, isForTrackedBranchOnly, commitId);
2932
var executeGitVersion = ExecuteGitVersion(gitVersionContext);
30-
var variables = VariableProvider.GetVariablesFor(executeGitVersion, gitVersionContext.Configuration, gitVersionContext.IsCurrentCommitTagged);
33+
var variables = variableProvider.GetVariablesFor(executeGitVersion, gitVersionContext.Configuration, gitVersionContext.IsCurrentCommitTagged);
3134
try
3235
{
3336
return variables;
@@ -69,7 +72,7 @@ public static void AssertFullSemver(this RepositoryFixtureBase fixture, Config c
6972
static SemanticVersion ExecuteGitVersion(GitVersionContext context)
7073
{
7174
var vf = new GitVersionFinder();
72-
return vf.FindVersion(context);
75+
return vf.FindVersion(new NullLog(), context);
7376
}
7477

7578
/// <summary>

src/GitVersionCore.Tests/GitVersionInformationGeneratorTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Shouldly;
66
using GitVersion.OutputVariables;
77
using GitVersion.Extensions.GitVersionInformationResources;
8+
using GitVersion.Log;
89

910
namespace GitVersionCore.Tests
1011
{
@@ -40,7 +41,8 @@ public void ShouldCreateFile(string fileExtension)
4041
"feature1", "commitSha", "commitShortSha", DateTimeOffset.Parse("2014-03-06 23:59:59Z"))
4142
};
4243

43-
var variables = VariableProvider.GetVariablesFor(semanticVersion, new TestEffectiveConfiguration(), false);
44+
var variableProvider = new VariableProvider(new NullLog());
45+
var variables = variableProvider.GetVariablesFor(semanticVersion, new TestEffectiveConfiguration(), false);
4446
var generator = new GitVersionInformationGenerator(fileName, directory, variables, fileSystem);
4547

4648
generator.Generate();

src/GitVersionCore.Tests/Init/InitScenarios.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.IO;
22
using System.Runtime.InteropServices;
33
using GitVersion.Configuration;
4+
using GitVersion.Log;
45
using NUnit.Framework;
56
using Shouldly;
67

@@ -20,11 +21,12 @@ public void Setup()
2021
[Description("Won't run on Mono due to source information not being available for ShouldMatchApproved.")]
2122
public void CanSetNextVersion()
2223
{
24+
var log = new NullLog();
2325
var testFileSystem = new TestFileSystem();
2426
var testConsole = new TestConsole("3", "2.0.0", "0");
2527
var configFileLocator = new DefaultConfigFileLocator();
2628
var workingDirectory = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "c:\\proj" : "/proj";
27-
ConfigurationProvider.Init(workingDirectory, testFileSystem, testConsole, configFileLocator);
29+
ConfigurationProvider.Init(workingDirectory, testFileSystem, testConsole, log, configFileLocator);
2830

2931
testFileSystem.ReadAllText(Path.Combine(workingDirectory, "GitVersion.yml")).ShouldMatchApproved();
3032
}

src/GitVersionCore.Tests/JsonVersionBuilderTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using GitVersion;
3+
using GitVersion.Log;
34
using NUnit.Framework;
45
using Shouldly;
56
using GitVersion.OutputFormatters;
@@ -32,7 +33,8 @@ public void Json()
3233

3334
var config = new TestEffectiveConfiguration();
3435

35-
var variables = VariableProvider.GetVariablesFor(semanticVersion, config, false);
36+
var variableProvider = new VariableProvider(new NullLog());
37+
var variables = variableProvider.GetVariablesFor(semanticVersion, config, false);
3638
var json = JsonOutputFormatter.ToJson(variables);
3739
json.ShouldMatchApproved(c => c.SubFolder("Approved"));
3840
}

0 commit comments

Comments
 (0)