-
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.
* Add core project with models * Define interfaces for endpoints * Implement endpoints * Implement AddAttachment endpoint * Add docs to HttpClient * Update solution structure * Add package info * Update csproj * Update project structure * Implement Configuration * Add IConfiguration interface * Rename constant * Fix typo * Rename method * Fix comments, add DI startup * Update startup
- Loading branch information
Showing
29 changed files
with
860 additions
and
1 deletion.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
AqualityTracking.Integrations/AqualityTracking.Integrations.sln
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,30 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.30002.166 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AqualityTracking.Integrations.Core", "src\AqualityTracking.Integrations.Core\AqualityTracking.Integrations.Core.csproj", "{0FE70831-5707-48AA-AD1E-8EC02E04C177}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{38B81A9B-FA2A-425C-BEB5-40E69E0005CE}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{0FE70831-5707-48AA-AD1E-8EC02E04C177}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{0FE70831-5707-48AA-AD1E-8EC02E04C177}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{0FE70831-5707-48AA-AD1E-8EC02E04C177}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{0FE70831-5707-48AA-AD1E-8EC02E04C177}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(NestedProjects) = preSolution | ||
{0FE70831-5707-48AA-AD1E-8EC02E04C177} = {38B81A9B-FA2A-425C-BEB5-40E69E0005CE} | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {CC3B552A-F385-48E0-8496-DE13B78ECAED} | ||
EndGlobalSection | ||
EndGlobal |
7 changes: 7 additions & 0 deletions
7
AqualityTracking.Integrations/src/AqualityTracking.Integrations.Core/AqualityConstants.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,7 @@ | ||
namespace AqualityTracking.Integrations.Core | ||
{ | ||
public static class AqualityConstants | ||
{ | ||
public static readonly string SettingsFileName = "aqualityTracking.json"; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
AqualityTracking.Integrations/src/AqualityTracking.Integrations.Core/AqualityException.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,11 @@ | ||
using System; | ||
|
||
namespace AqualityTracking.Integrations.Core | ||
{ | ||
public class AqualityException : Exception | ||
{ | ||
public AqualityException(string message) : base(message) | ||
{ | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...grations/src/AqualityTracking.Integrations.Core/AqualityTracking.Integrations.Core.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,39 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
|
||
<GeneratePackageOnBuild>false</GeneratePackageOnBuild> | ||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance> | ||
<Authors>aquality automation committers</Authors> | ||
<Company>aquality automation</Company> | ||
<Description>Aquality Tracking integration core for .NET test frameworks.</Description> | ||
<PackageDescription>Aquality Tracking integration core for .NET test frameworks.</PackageDescription> | ||
<PackageLicenseExpression></PackageLicenseExpression> | ||
<RepositoryUrl>https://github.com/aquality-automation/aquality-tracking-integrations-dotnet</RepositoryUrl> | ||
<RepositoryType>git</RepositoryType> | ||
<PackageTags>aquality-tracking</PackageTags> | ||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | ||
<Copyright>Copyright 2020 Aquality Automation</Copyright> | ||
<IsPackable>true</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\..\..\LICENSE"> | ||
<Pack>True</Pack> | ||
<PackagePath></PackagePath> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="Resources\aqualityTracking.Template.json"> | ||
<Pack>True</Pack> | ||
</Content> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.4" /> | ||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> | ||
</ItemGroup> | ||
|
||
</Project> |
95 changes: 95 additions & 0 deletions
95
...ntegrations/src/AqualityTracking.Integrations.Core/Configuration/AqualityConfiguration.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,95 @@ | ||
using AqualityTracking.Integrations.Core.Utilities; | ||
using Newtonsoft.Json.Linq; | ||
using System.ComponentModel; | ||
|
||
namespace AqualityTracking.Integrations.Core.Configuration | ||
{ | ||
public class AqualityConfiguration : IConfiguration | ||
{ | ||
private bool enabled; | ||
private string host; | ||
private string token; | ||
private int projectId; | ||
private string executor; | ||
private string suiteName; | ||
private string buildName; | ||
private string environment; | ||
private string ciBuild; | ||
private bool debug; | ||
|
||
public bool Enabled | ||
{ | ||
get { return GetEnvValueOrDefault("aquality.enabled", enabled); } | ||
set { enabled = value; } | ||
} | ||
|
||
public string Host | ||
{ | ||
get { return GetEnvValueOrDefault("aquality.host", host); } | ||
set { host = value; } | ||
} | ||
|
||
public string Token | ||
{ | ||
get { return GetEnvValueOrDefault("aquality.token", token); } | ||
set { token = value; } | ||
} | ||
|
||
public int ProjectId | ||
{ | ||
get { return GetEnvValueOrDefault("aquality.projectId", projectId); } | ||
set { projectId = value; } | ||
} | ||
|
||
public string Executor | ||
{ | ||
get { return GetEnvValueOrDefault("aquality.executor", executor); } | ||
set { executor = value; } | ||
} | ||
|
||
public string SuiteName | ||
{ | ||
get { return GetEnvValueOrDefault("aquality.suiteName", suiteName); } | ||
set { suiteName = value; } | ||
} | ||
|
||
public string BuildName | ||
{ | ||
get { return GetEnvValueOrDefault("aquality.buildName", buildName); } | ||
set { buildName = value; } | ||
} | ||
|
||
public string Environment | ||
{ | ||
get { return GetEnvValueOrDefault("aquality.environment", environment); } | ||
set { environment = value; } | ||
} | ||
|
||
public string CiBuild | ||
{ | ||
get { return GetEnvValueOrDefault("aquality.ciBuild", ciBuild); } | ||
set { ciBuild = value; } | ||
} | ||
|
||
public bool Debug | ||
{ | ||
get { return GetEnvValueOrDefault("aquality.debug", debug); } | ||
set { debug = value; } | ||
} | ||
|
||
private T GetEnvValueOrDefault<T>(string key, T defaultValue) | ||
{ | ||
var envValue = EnvironmentReader.GetVariable(key); | ||
if (envValue != null) | ||
{ | ||
return (T) TypeDescriptor.GetConverter(typeof(T)).ConvertFrom(envValue); | ||
} | ||
return defaultValue; | ||
} | ||
|
||
public static AqualityConfiguration ParseFromJson(string json) | ||
{ | ||
return JObject.Parse(json)?.ToObject<AqualityConfiguration>(); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...cking.Integrations/src/AqualityTracking.Integrations.Core/Configuration/IConfiguration.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,25 @@ | ||
namespace AqualityTracking.Integrations.Core.Configuration | ||
{ | ||
public interface IConfiguration | ||
{ | ||
bool Enabled { get; set; } | ||
|
||
string Host { get; set; } | ||
|
||
string Token { get; set; } | ||
|
||
int ProjectId { get; set; } | ||
|
||
string Executor { get; set; } | ||
|
||
string SuiteName { get; set; } | ||
|
||
string BuildName { get; set; } | ||
|
||
string Environment { get; set; } | ||
|
||
string CiBuild { get; set; } | ||
|
||
bool Debug { get; set; } | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...Tracking.Integrations/src/AqualityTracking.Integrations.Core/Endpoints/ISuiteEndpoints.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,14 @@ | ||
using AqualityTracking.Integrations.Core.Models; | ||
|
||
namespace AqualityTracking.Integrations.Core.Endpoints | ||
{ | ||
public interface ISuiteEndpoints | ||
{ | ||
/// <summary> | ||
/// Creates new suite or gets the existing one. | ||
/// </summary> | ||
/// <param name="name">Name of suite.</param> | ||
/// <returns>Instance of created or found Suite.</returns> | ||
Suite CreateSuite(string name); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...yTracking.Integrations/src/AqualityTracking.Integrations.Core/Endpoints/ITestEndpoints.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 @@ | ||
using AqualityTracking.Integrations.Core.Models; | ||
using System.Collections.Generic; | ||
|
||
namespace AqualityTracking.Integrations.Core.Endpoints | ||
{ | ||
public interface ITestEndpoints | ||
{ | ||
/// <summary> | ||
/// Creates new Test or updates and gets the existing one. | ||
/// Does not override the existing suites, adds a missing ones. | ||
/// </summary> | ||
/// <param name="name">Name of Test.</param> | ||
/// <param name="suites">List of Suites that Test belongs to.</param> | ||
/// <returns>Instance of new or updated Test.</returns> | ||
Test CreateOrUpdateTest(string name, IList<Suite> suites); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...ing.Integrations/src/AqualityTracking.Integrations.Core/Endpoints/ITestResultEndpoints.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,31 @@ | ||
using AqualityTracking.Integrations.Core.Models; | ||
|
||
namespace AqualityTracking.Integrations.Core.Endpoints | ||
{ | ||
public interface ITestResultEndpoints | ||
{ | ||
/// <summary> | ||
/// Starts new Test execution. | ||
/// </summary> | ||
/// <param name="testRunId">Id of current Test Run.</param> | ||
/// <param name="testId">Id of Test to execute.</param> | ||
/// <returns>Instance of started Test execution (Test Result).</returns> | ||
TestResult StartTestResult(int testRunId, int testId); | ||
|
||
/// <summary> | ||
/// Sets Test Result. | ||
/// </summary> | ||
/// <param name="testResultId">Id of Test Result to finish.</param> | ||
/// <param name="finalResultId">Id of the result.</param> | ||
/// <param name="failReason">Reason of test failure. If not needed - pass null.</param> | ||
/// <returns>Instance of finished Test Result.</returns> | ||
TestResult FinishTestResult(int testResultId, FinalResultId finalResultId, string failReason); | ||
|
||
/// <summary> | ||
/// Add attachment to Test Result. | ||
/// </summary> | ||
/// <param name="testResultId">Id of Test Result.</param> | ||
/// <param name="filePath">Path to attachment file.</param> | ||
void AddAttachment(int testResultId, string filePath); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...acking.Integrations/src/AqualityTracking.Integrations.Core/Endpoints/ITestRunEndpoints.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,30 @@ | ||
using AqualityTracking.Integrations.Core.Models; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace AqualityTracking.Integrations.Core.Endpoints | ||
{ | ||
public interface ITestRunEndpoints | ||
{ | ||
/// <summary> | ||
/// Starts new Test Run. | ||
/// </summary> | ||
/// <param name="testSuiteId">Id of Test Suite which included in Test Run.</param> | ||
/// <param name="buildName">Name of current build.</param> | ||
/// <param name="environment">Name of execution environment.</param> | ||
/// <param name="executor">Name of author.</param> | ||
/// <param name="ciBuild">Link to the CI build of current Test Run.</param> | ||
/// <param name="debug">Debug (true) or regular (false) execution. If debug Test Run won't be present in Aquality Tracking.</param> | ||
/// <returns>Instance of started Test Run.</returns> | ||
TestRun StartTestRun(int testSuiteId, string buildName, string environment, | ||
string executor, string ciBuild, bool debug); | ||
|
||
/// <summary> | ||
/// Finished Test Run. | ||
/// </summary> | ||
/// <param name="testRunId">Id of Test Run which should be finished.</param> | ||
/// <returns>Instance of finished Test Run.</returns> | ||
TestRun FinishTestRun(int testRunId); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...ations/src/AqualityTracking.Integrations.Core/Endpoints/Impl/AqualityTrackingEndpoints.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,24 @@ | ||
using AqualityTracking.Integrations.Core.Configuration; | ||
using AqualityTracking.Integrations.Core.Http; | ||
using AqualityTracking.Integrations.Core.Utilities; | ||
|
||
namespace AqualityTracking.Integrations.Core.Endpoints.Impl | ||
{ | ||
public abstract class AqualityTrackingEndpoints | ||
{ | ||
public AqualityTrackingEndpoints(IConfiguration configuration, IHttpClient httpClient) | ||
{ | ||
Configuration = configuration; | ||
HttpClient = httpClient; | ||
} | ||
|
||
protected IConfiguration Configuration { get; } | ||
|
||
protected IHttpClient HttpClient { get; } | ||
|
||
protected UriBuilder GetUriBuilder(string path) | ||
{ | ||
return new UriBuilder(Configuration.Host).SetPath(path); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...king.Integrations/src/AqualityTracking.Integrations.Core/Endpoints/Impl/SuiteEndpoints.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,27 @@ | ||
using AqualityTracking.Integrations.Core.Configuration; | ||
using AqualityTracking.Integrations.Core.Http; | ||
using AqualityTracking.Integrations.Core.Models; | ||
|
||
namespace AqualityTracking.Integrations.Core.Endpoints.Impl | ||
{ | ||
public class SuiteEndpoints : AqualityTrackingEndpoints, ISuiteEndpoints | ||
{ | ||
private const string CreateOrUpdateEndpoint = "/api/public/suite/create-or-update"; | ||
|
||
public SuiteEndpoints(IConfiguration configuration, IHttpClient httpClient) : base(configuration, httpClient) | ||
{ | ||
} | ||
|
||
public Suite CreateSuite(string name) | ||
{ | ||
var suite = new Suite | ||
{ | ||
Name = name, | ||
ProjectId = Configuration.ProjectId | ||
}; | ||
var uri = GetUriBuilder(CreateOrUpdateEndpoint).Uri; | ||
|
||
return HttpClient.SendPOST(uri, suite); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...cking.Integrations/src/AqualityTracking.Integrations.Core/Endpoints/Impl/TestEndpoints.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,29 @@ | ||
using AqualityTracking.Integrations.Core.Configuration; | ||
using AqualityTracking.Integrations.Core.Http; | ||
using AqualityTracking.Integrations.Core.Models; | ||
using System.Collections.Generic; | ||
|
||
namespace AqualityTracking.Integrations.Core.Endpoints.Impl | ||
{ | ||
public class TestEndpoints : AqualityTrackingEndpoints, ITestEndpoints | ||
{ | ||
private const string CreateOrUpdateTestEndpoint = "/api/public/test/create-or-update"; | ||
|
||
public TestEndpoints(IConfiguration configuration, IHttpClient httpClient) : base(configuration, httpClient) | ||
{ | ||
} | ||
|
||
public Test CreateOrUpdateTest(string name, IList<Suite> suites) | ||
{ | ||
var test = new Test | ||
{ | ||
ProjectId = Configuration.ProjectId, | ||
Name = name, | ||
Suites = suites | ||
}; | ||
var uri = GetUriBuilder(CreateOrUpdateTestEndpoint).Uri; | ||
|
||
return HttpClient.SendPOST(uri, test); | ||
} | ||
} | ||
} |
Oops, something went wrong.