-
Notifications
You must be signed in to change notification settings - Fork 14
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
Showing
6 changed files
with
236 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
namespace Clio.Tests.Command | ||
{ | ||
using Clio.Command; | ||
using Clio.Command.PackageCommand; | ||
using Clio.Common; | ||
using NSubstitute; | ||
using NUnit.Framework; | ||
|
||
[TestFixture] | ||
public class UploadLicensesCommandTestCase | ||
{ | ||
private UploadLicensesCommandTestable _command; | ||
|
||
[SetUp] | ||
public void SetUp() { | ||
_command = new UploadLicensesCommandTestable(Substitute.For<IApplicationClient>(), | ||
Substitute.For<EnvironmentSettings>()); | ||
} | ||
|
||
[Test] | ||
public void TestProceedResponse_SuccessResponse_DoesNotThrow() { | ||
var response = "{\"success\": true}"; | ||
var options = new UploadLicensesOptions(); | ||
Assert.DoesNotThrow(() => _command.TestProceedResponse(response, options)); | ||
} | ||
|
||
[Test] | ||
public void TestProceedResponse_ErrorResponseWithErrorInfo_ThrowsException() { | ||
var response = @" | ||
{ | ||
""success"": false, | ||
""errorInfo"": { | ||
""message"": ""Invalid license key"", | ||
""errorCode"": ""INVALID_KEY"" | ||
} | ||
}"; | ||
var options = new UploadLicensesOptions(); | ||
var ex = Assert.Throws<LicenseInstallationException>(() => | ||
_command.TestProceedResponse(response, options)); | ||
Assert.That(ex.Message, | ||
Is.EqualTo("License not installed. ErrorCode: INVALID_KEY, Message: Invalid license key")); | ||
} | ||
|
||
[Test] | ||
public void TestProceedResponse_ErrorResponseWithoutErrorInfo_ThrowsException() { | ||
var response = "{\"success\": false}"; | ||
var options = new UploadLicensesOptions(); | ||
var ex = Assert.Throws<LicenseInstallationException>(() => | ||
_command.TestProceedResponse(response, options)); | ||
Assert.That(ex.Message, Is.EqualTo("License not installed: Unknown error details")); | ||
} | ||
|
||
[Test] | ||
public void TestProceedResponse_ResponseWithoutSuccessProperty_DoesNotThrow() { | ||
var response = "{\"errorInfo\": { \"message\": \"Error occurred\" }}"; | ||
var options = new UploadLicensesOptions(); | ||
Assert.DoesNotThrow(() => _command.TestProceedResponse(response, options)); | ||
} | ||
|
||
[Test] | ||
public void TestProceedResponse_AuthenticationFailed_ThrowsLicenseInstallationException() { | ||
var response = "{\"Message\":\"Authentication failed.\",\"StackTrace\":null,\"ExceptionType\":\"System.InvalidOperationException\"}"; | ||
var options = new UploadLicensesOptions(); | ||
var ex = Assert.Throws<LicenseInstallationException>(() => | ||
_command.TestProceedResponse(response, options)); | ||
Assert.That(ex.Message, Is.EqualTo("License not installed: Authentication failed.")); | ||
} | ||
} | ||
|
||
public class UploadLicensesCommandTestable : UploadLicensesCommand | ||
{ | ||
public UploadLicensesCommandTestable(IApplicationClient applicationClient, EnvironmentSettings settings) | ||
: base(applicationClient, settings) { | ||
} | ||
|
||
public void TestProceedResponse(string response, UploadLicensesOptions options) { | ||
ProceedResponse(response, options); | ||
} | ||
} | ||
|
||
|
||
} |
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,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
using Newtonsoft.Json; | ||
|
||
namespace Clio.Command.StartProcess; | ||
|
||
[JsonObject] | ||
public record ProcessStartArgs | ||
{ | ||
|
||
[JsonObject] | ||
public class ParameterValues | ||
{ | ||
[JsonPropertyName("name")] | ||
[JsonProperty("name")] | ||
public string Name { get; init; } | ||
|
||
[JsonPropertyName("value")] | ||
[JsonProperty("value")] | ||
public string Value { get; init; } | ||
} | ||
|
||
[JsonProperty("schemaName")] | ||
[JsonPropertyName("schemaName")] | ||
public string SchemaName { get; init; } | ||
|
||
[JsonProperty("parameterValues")] | ||
[JsonPropertyName("parameterValues")] | ||
public ParameterValues[] Values { get; init; } | ||
|
||
[JsonProperty("resultParameterNames")] | ||
[JsonPropertyName("resultParameterNames")] | ||
public string[] Result { get; init; } | ||
|
||
} | ||
|
||
|
||
[JsonObject] | ||
public record ProcessStartResponse | ||
{ | ||
[JsonPropertyName("processId")] | ||
[JsonProperty("processId")] | ||
public Guid ProcessId { get; init; } | ||
|
||
[JsonPropertyName("processStatus")] | ||
[JsonProperty("processStatus")] | ||
public int ProcessStatus { get; init; } | ||
|
||
[JsonPropertyName("resultParameterValues")] | ||
[JsonProperty("resultParameterValues")] | ||
public Dictionary<string, object> ResultParameterValues { get; init; } | ||
|
||
[JsonPropertyName("executionData")] | ||
[JsonProperty("executionData")] | ||
public object ExecutionData { get; init; } | ||
|
||
[JsonPropertyName("success")] | ||
[JsonProperty("success")] | ||
public bool Success { get; init; } | ||
|
||
[JsonPropertyName("errorInfo")] | ||
[JsonProperty("errorInfo")] | ||
public object ErrorInfo { get; init; } | ||
} |
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