-
-
Notifications
You must be signed in to change notification settings - Fork 732
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add alias for dotnet sdk check command
- Loading branch information
Showing
6 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/Cake.Common.Tests/Fixtures/Tools/DotNet/SDKCheck/DotNetSDKCheckerFixture.cs
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,17 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Cake.Common.Tools.DotNet.SDKCheck; | ||
|
||
namespace Cake.Common.Tests.Fixtures.Tools.DotNet.SDKCheck | ||
{ | ||
internal sealed class DotNetSDKCheckerFixture : DotNetFixture<DotNetSDKCheckSettings> | ||
{ | ||
protected override void RunTool() | ||
{ | ||
var tool = new DotNetSDKChecker(FileSystem, Environment, ProcessRunner, Tools); | ||
tool.Check(); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/Cake.Common.Tests/Unit/Tools/DotNet/SDKCheck/DotNetSDKCheckTests.cs
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,44 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Cake.Common.Tests.Fixtures.Tools.DotNet.SDKCheck; | ||
using Cake.Testing; | ||
using Xunit; | ||
|
||
namespace Cake.Common.Tests.Unit.Tools.DotNet.SDKCheck | ||
{ | ||
public sealed class DotNetSDKCheckTests | ||
{ | ||
public sealed class TheSDKCheckMethod | ||
{ | ||
[Fact] | ||
public void Should_Throw_If_Process_Was_Not_Started() | ||
{ | ||
// Given | ||
var fixture = new DotNetSDKCheckerFixture(); | ||
fixture.GivenProcessCannotStart(); | ||
|
||
// When | ||
var result = Record.Exception(() => fixture.Run()); | ||
|
||
// Then | ||
AssertEx.IsCakeException(result, ".NET CLI: Process was not started."); | ||
} | ||
|
||
[Fact] | ||
public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code() | ||
{ | ||
// Given | ||
var fixture = new DotNetSDKCheckerFixture(); | ||
fixture.GivenProcessExitsWithCode(1); | ||
|
||
// When | ||
var result = Record.Exception(() => fixture.Run()); | ||
|
||
// Then | ||
AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1)."); | ||
} | ||
} | ||
} | ||
} |
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
13 changes: 13 additions & 0 deletions
13
src/Cake.Common/Tools/DotNet/SDKCheck/DotNetSDKCheckSettings.cs
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,13 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace Cake.Common.Tools.DotNet.SDKCheck | ||
{ | ||
/// <summary> | ||
/// Contains settings used by <see cref="DotNetSDKChecker" />. | ||
/// </summary> | ||
public sealed class DotNetSDKCheckSettings : DotNetSettings | ||
{ | ||
} | ||
} |
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,52 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Cake.Core; | ||
using Cake.Core.IO; | ||
using Cake.Core.Tooling; | ||
|
||
namespace Cake.Common.Tools.DotNet.SDKCheck | ||
{ | ||
/// <summary> | ||
/// .NET SDK checker. | ||
/// </summary> | ||
public sealed class DotNetSDKChecker : DotNetTool<DotNetSDKCheckSettings> | ||
{ | ||
private readonly ICakeEnvironment _environment; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="DotNetSDKChecker" /> class. | ||
/// </summary> | ||
/// <param name="fileSystem">The file system.</param> | ||
/// <param name="environment">The environment.</param> | ||
/// <param name="processRunner">The process runner.</param> | ||
/// <param name="tools">The tool locator.</param> | ||
public DotNetSDKChecker( | ||
IFileSystem fileSystem, | ||
ICakeEnvironment environment, | ||
IProcessRunner processRunner, | ||
IToolLocator tools) : base(fileSystem, environment, processRunner, tools) | ||
{ | ||
_environment = environment; | ||
} | ||
|
||
/// <summary> | ||
/// Lists the latest available version of the .NET SDK and .NET Runtime, for each feature band. | ||
/// </summary> | ||
public void Check() | ||
{ | ||
var settings = new DotNetSDKCheckSettings(); | ||
RunCommand(settings, GetArguments(settings)); | ||
} | ||
|
||
private ProcessArgumentBuilder GetArguments(DotNetSDKCheckSettings settings) | ||
{ | ||
var builder = CreateArgumentBuilder(settings); | ||
|
||
builder.Append("sdk check"); | ||
|
||
return builder; | ||
} | ||
} | ||
} |
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