Skip to content

Commit 67f7f29

Browse files
committed
Adds tests to cover parsing project parameters
1 parent 7b04224 commit 67f7f29

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/GitVersionExe.Tests/ArgumentParserTests.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,16 @@ public void UpdateAssemblyInfoTrue(string command)
295295
arguments.UpdateAssemblyInfo.ShouldBe(true);
296296
}
297297

298+
[TestCase("-updateProjectFiles assemblyInfo.csproj")]
299+
[TestCase("-updateProjectFiles assemblyInfo.csproj")]
300+
[TestCase("-updateProjectFiles assemblyInfo.csproj otherAssemblyInfo.fsproj")]
301+
[TestCase("-updateProjectFiles")]
302+
public void UpdateProjectTrue(string command)
303+
{
304+
var arguments = argumentParser.ParseArguments(command);
305+
arguments.UpdateProjectFiles.ShouldBe(true);
306+
}
307+
298308
[TestCase("-updateAssemblyInfo false")]
299309
[TestCase("-updateAssemblyInfo 0")]
300310
public void UpdateAssemblyInfoFalse(string command)
@@ -310,6 +320,13 @@ public void CreateMulitpleAssemblyInfoProtected(string command)
310320
exception.Message.ShouldBe("Can't specify multiple assembly info files when using /ensureassemblyinfo switch, either use a single assembly info file or do not specify /ensureassemblyinfo and create assembly info files manually");
311321
}
312322

323+
[TestCase("-updateProjectFiles Assembly.csproj Assembly1.csproj -ensureassemblyinfo")]
324+
public void UpdateProjectInfoWithEnsureAssemblyInfoProtected(string command)
325+
{
326+
var exception = Assert.Throws<WarningException>(() => argumentParser.ParseArguments(command));
327+
exception.Message.ShouldBe("Cannot specify -ensureassemblyinfo with updateprojectfiles: please ensure your project file exists before attempting to update it");
328+
}
329+
313330
[Test]
314331
public void UpdateAssemblyInfoWithFilename()
315332
{
@@ -342,6 +359,24 @@ public void UpdateAssemblyInfoWithMultipleFilenames()
342359
arguments.UpdateAssemblyInfoFileName.ShouldContain(x => Path.GetFileName(x).Equals("VersionAssemblyInfo.cs"));
343360
}
344361

362+
[Test]
363+
public void UpdateProjectFilesWithMultipleFilenames()
364+
{
365+
using var repo = new EmptyRepositoryFixture();
366+
367+
var assemblyFile1 = Path.Combine(repo.RepositoryPath, "CommonAssemblyInfo.csproj");
368+
using var file = File.Create(assemblyFile1);
369+
370+
var assemblyFile2 = Path.Combine(repo.RepositoryPath, "VersionAssemblyInfo.csproj");
371+
using var file2 = File.Create(assemblyFile2);
372+
373+
var arguments = argumentParser.ParseArguments($"-targetpath {repo.RepositoryPath} -updateProjectFiles CommonAssemblyInfo.csproj VersionAssemblyInfo.csproj");
374+
arguments.UpdateProjectFiles.ShouldBe(true);
375+
arguments.UpdateAssemblyInfoFileName.Count.ShouldBe(2);
376+
arguments.UpdateAssemblyInfoFileName.ShouldContain(x => Path.GetFileName(x).Equals("CommonAssemblyInfo.csproj"));
377+
arguments.UpdateAssemblyInfoFileName.ShouldContain(x => Path.GetFileName(x).Equals("VersionAssemblyInfo.csproj"));
378+
}
379+
345380
[Test]
346381
public void UpdateAssemblyInfoWithMultipleFilenamesMatchingGlobbing()
347382
{

0 commit comments

Comments
 (0)