Skip to content

Commit 4b4f496

Browse files
committed
moves executable helper to app tests
moves the executable helper from core tests to app tests to improve project structure and dependencies. This change also refactors the test environment to use the TestEnvironment class instead of the interface. It also adds an IsEmpty property to IIgnoreConfiguration and IgnoreConfiguration.
1 parent 2adff77 commit 4b4f496

File tree

10 files changed

+13
-11
lines changed

10 files changed

+13
-11
lines changed

src/GitVersion.App.Tests/ExecCmdLineArgumentTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using GitVersion.Core.Tests.Helpers;
1+
using GitVersion.App.Tests.Helpers;
22
using GitVersion.Helpers;
33

44
namespace GitVersion.App.Tests;

src/GitVersion.App.Tests/GitVersion.App.Tests.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<Content Include="Approved\**\*.approved.txt" />
1717
</ItemGroup>
1818
<ItemGroup>
19-
<Compile Include="..\GitVersion.Core.Tests\Helpers\ExecutableHelper.cs" Link="Helpers\ExecutableHelper.cs" />
2019
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestConsoleAdapter.cs" Link="Helpers\TestConsoleAdapter.cs" />
2120
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestEnvironment.cs" Link="Helpers\TestEnvironment.cs" />
2221
<Compile Include="..\GitVersion.Core.Tests\Helpers\TestLogAppender.cs" Link="Helpers\TestLogAppender.cs" />

src/GitVersion.Core.Tests/Helpers/ExecutableHelper.cs renamed to src/GitVersion.App.Tests/Helpers/ExecutableHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using GitVersion.Helpers;
22

3-
namespace GitVersion.Core.Tests.Helpers;
3+
namespace GitVersion.App.Tests.Helpers;
44

55
public static class ExecutableHelper
66
{

src/GitVersion.App.Tests/Helpers/GitVersionHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using GitVersion.Agents;
2-
using GitVersion.Core.Tests.Helpers;
2+
using GitVersion.App.Tests.Helpers;
33
using GitVersion.Extensions;
44
using GitVersion.Helpers;
55

src/GitVersion.App.Tests/Helpers/ProgramFixture.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace GitVersion.App.Tests;
77

88
public sealed class ProgramFixture
99
{
10-
private readonly IEnvironment environment;
10+
private readonly TestEnvironment environment;
1111
private List<Action<IServiceCollection>> Overrides { get; } = [];
1212
private readonly Lazy<string> logger;
1313
private readonly Lazy<string?> output;
@@ -30,7 +30,7 @@ public ProgramFixture(string workingDirectory = "")
3030
{
3131
services.AddSingleton(log);
3232
services.AddSingleton<IConsole>(consoleAdapter);
33-
services.AddSingleton(this.environment);
33+
services.AddSingleton<IEnvironment>(this.environment);
3434
});
3535

3636
this.logger = new(() => logBuilder.ToString());

src/GitVersion.Configuration.Tests/Configuration/IgnoreConfigurationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void WhenBadDateFormatShouldFail()
7575
[Test]
7676
public void NewInstanceShouldBeEmpty()
7777
{
78-
IIgnoreConfiguration ignoreConfig = new IgnoreConfiguration();
78+
var ignoreConfig = new IgnoreConfiguration();
7979

8080
ignoreConfig.IsEmpty.ShouldBeTrue();
8181
}

src/GitVersion.Configuration/IgnoreConfiguration.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ public string? BeforeString
2222
[JsonPropertyName("sha")]
2323
[JsonPropertyDescription("A sequence of SHAs to be excluded from the version calculations.")]
2424
public HashSet<string> Shas { get; init; } = [];
25+
26+
[JsonIgnore]
27+
public bool IsEmpty => Before == null && Shas.Count == 0;
2528
}

src/GitVersion.Core.Tests/Extensions/StringFormatWithExtensionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace GitVersion.Core.Tests;
66
[TestFixture]
77
public class StringFormatWithExtensionTests
88
{
9-
private IEnvironment environment;
9+
private TestEnvironment environment;
1010

1111
[SetUp]
1212
public void Setup() => this.environment = new TestEnvironment();

src/GitVersion.Core/Configuration/IIgnoreConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ public interface IIgnoreConfiguration
66

77
IReadOnlySet<string> Shas { get; }
88

9-
bool IsEmpty => Before == null && Shas.Count == 0;
9+
bool IsEmpty { get; }
1010
}

src/GitVersion.Output.Tests/Output/FormatArgumentTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void ShouldOutputFormatWithEnvironmentVariablesTests(string format, strin
4646
var fixture = CreateTestRepository();
4747
var consoleBuilder = new StringBuilder();
4848
IConsole console = new TestConsoleAdapter(consoleBuilder);
49-
IEnvironment environment = new TestEnvironment();
49+
var environment = new TestEnvironment();
5050
environment.SetEnvironmentVariable("CustomVar", "foo");
5151

5252
var sp = ConfigureServices(services =>
@@ -57,7 +57,7 @@ public void ShouldOutputFormatWithEnvironmentVariablesTests(string format, strin
5757
services.AddSingleton(options);
5858
services.AddSingleton(repository);
5959
services.AddSingleton(console);
60-
services.AddSingleton(environment);
60+
services.AddSingleton<IEnvironment>(environment);
6161
});
6262

6363
var versionVariables = sp.GetRequiredService<IGitVersionCalculateTool>().CalculateVersionVariables();

0 commit comments

Comments
 (0)