Skip to content

Commit c1cbdb0

Browse files
committed
Add unit test prior to refactoring
1 parent 14c52da commit c1cbdb0

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) .NET Foundation and Contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using Nerdbank.GitVersioning;
5+
using Nerdbank.GitVersioning.Commands;
6+
using Xunit;
7+
8+
public class CommandTests : RepoTestBase
9+
{
10+
private readonly TestOutputHelperToTextWriterAdapter adapter;
11+
12+
public CommandTests(ITestOutputHelper logger)
13+
: base(logger)
14+
{
15+
this.adapter = new(logger);
16+
}
17+
18+
// TODO: This is tightly coupled to the cloud build service. Can I use a FakeCloudBuildService instead?
19+
[Theory]
20+
[InlineData("VisualStudioTeamServices")]
21+
[InlineData("TeamCity")]
22+
[InlineData("Jenkins")]
23+
public void CloudCommand_BuildNumber(string ciSystem)
24+
{
25+
var outWriter = new StringWriter();
26+
var errWriter = new StringWriter();
27+
28+
var command = new CloudCommand(outWriter, errWriter);
29+
30+
command.SetBuildVariables(this.RepoPath, metadata: [], version: "1.2.3.4", ciSystem, allVars: false, commonVars: false, additionalVariables: [], alwaysUseLibGit2: false);
31+
32+
outWriter.Flush();
33+
errWriter.Flush();
34+
Assert.NotEmpty(outWriter.ToString());
35+
Assert.Empty(errWriter.ToString());
36+
}
37+
38+
protected override GitContext CreateGitContext(string path, string committish = null)
39+
=> GitContext.Create(path, committish, engine: GitContext.Engine.ReadWrite);
40+
}

0 commit comments

Comments
 (0)