forked from Heleonix/Heleonix.Build
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b94d451
commit fcecf16
Showing
17 changed files
with
729 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
test/Heleonix.Build.Tests.ExeMock/Heleonix.Build.Tests.ExeMock.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
if(args.Any(a => a.Contains("ERROR"))) | ||
{ | ||
Console.Error.Write("ERROR details"); | ||
|
||
Console.Write("ERROR simulated"); | ||
|
||
return 1; | ||
} | ||
|
||
Console.Write(string.Join(' ', args)); | ||
|
||
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// <copyright file="ProgramTests.cs" company="Heleonix - Hennadii Lutsyshyn"> | ||
// Copyright (c) Heleonix - Hennadii Lutsyshyn. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the repository root for full license information. | ||
// </copyright> | ||
|
||
namespace Heleonix.Build.Tests; | ||
|
||
/// <summary> | ||
/// Tests the <see cref="Program"/>. | ||
/// </summary> | ||
[ComponentTest(Type = typeof(Program))] | ||
|
||
public static class ProgramTests | ||
{ | ||
/// <summary> | ||
/// Tests the <see cref="Program.Main"/>. | ||
/// </summary> | ||
[MemberTest(Name = nameof(Program.Main))] | ||
|
||
public static void MainTests() | ||
{ | ||
string[] args = null; | ||
string outptut = null; | ||
string errors = null; | ||
var returnValue = 0; | ||
|
||
Act(() => | ||
{ | ||
using var outWriter = new StringWriter(); | ||
using var errorWriter = new StringWriter(); | ||
|
||
Console.SetOut(outWriter); | ||
Console.SetError(errorWriter); | ||
|
||
returnValue = Program.Main(args); | ||
|
||
outptut = outWriter.ToString(); | ||
errors = errorWriter.ToString(); | ||
}); | ||
|
||
When("the help command is called", () => | ||
{ | ||
And("the short form is specified", () => | ||
{ | ||
args = new string[] { "-h" }; | ||
|
||
Should("display information about the tool", () => | ||
{ | ||
Assert.That(returnValue, Is.Zero); | ||
Assert.That(outptut, Contains.Substring("Description:")); | ||
Assert.That(outptut, Contains.Substring("Version:")); | ||
Assert.That(outptut, Contains.Substring("More:")); | ||
Assert.That(outptut, Contains.Substring("Options:")); | ||
Assert.That(outptut, Contains.Substring("Examples:")); | ||
}); | ||
}); | ||
|
||
And("the long form is specified", () => | ||
{ | ||
args = new string[] { "--help" }; | ||
|
||
Should("display information about the tool", () => | ||
{ | ||
Assert.That(returnValue, Is.Zero); | ||
Assert.That(outptut, Contains.Substring("Description:")); | ||
Assert.That(outptut, Contains.Substring("Version:")); | ||
Assert.That(outptut, Contains.Substring("More:")); | ||
Assert.That(outptut, Contains.Substring("Options:")); | ||
Assert.That(outptut, Contains.Substring("Examples:")); | ||
}); | ||
}); | ||
}); | ||
|
||
When("the '--exe' value is not provided", () => | ||
{ | ||
args = new string[] { "--exe" }; | ||
|
||
Should("retun the error code: 1", () => | ||
{ | ||
Assert.That(returnValue, Is.EqualTo(1)); | ||
Assert.That( | ||
errors, | ||
Contains.Substring("The dotnet executable path is not defined for the specified argument '--exe'.")); | ||
}); | ||
}); | ||
|
||
When("the --exe value is provided", () => | ||
{ | ||
args = new string[] { "--exe", "dotnet.exe", "-p:Hx_WS_RepositoryUrl=https://example.com" }; | ||
|
||
Should("run the provided dotnet executable with passed command-line arguments", () => | ||
{ | ||
Assert.That(returnValue, Is.Zero); | ||
Assert.That(outptut, Contains.Substring("https://example.com")); | ||
}); | ||
}); | ||
|
||
When("the default dotnet.exe is used", () => | ||
{ | ||
args = new string[] { "-p:Hx_WS_RepositoryUrl=https://example.com" }; | ||
|
||
Should("run the provided dotnet executable with passed command-line arguments", () => | ||
{ | ||
Assert.That(returnValue, Is.Zero); | ||
Assert.That(outptut, Contains.Substring("https://example.com")); | ||
}); | ||
}); | ||
} | ||
} |
Oops, something went wrong.