Skip to content

Commit 0e9a75a

Browse files
authored
Feature/1 core (#2)
* 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
1 parent 323e1ef commit 0e9a75a

29 files changed

+860
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30002.166
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AqualityTracking.Integrations.Core", "src\AqualityTracking.Integrations.Core\AqualityTracking.Integrations.Core.csproj", "{0FE70831-5707-48AA-AD1E-8EC02E04C177}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{38B81A9B-FA2A-425C-BEB5-40E69E0005CE}"
9+
EndProject
10+
Global
11+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
12+
Debug|Any CPU = Debug|Any CPU
13+
Release|Any CPU = Release|Any CPU
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{0FE70831-5707-48AA-AD1E-8EC02E04C177}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{0FE70831-5707-48AA-AD1E-8EC02E04C177}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{0FE70831-5707-48AA-AD1E-8EC02E04C177}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{0FE70831-5707-48AA-AD1E-8EC02E04C177}.Release|Any CPU.Build.0 = Release|Any CPU
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(NestedProjects) = preSolution
25+
{0FE70831-5707-48AA-AD1E-8EC02E04C177} = {38B81A9B-FA2A-425C-BEB5-40E69E0005CE}
26+
EndGlobalSection
27+
GlobalSection(ExtensibilityGlobals) = postSolution
28+
SolutionGuid = {CC3B552A-F385-48E0-8496-DE13B78ECAED}
29+
EndGlobalSection
30+
EndGlobal
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace AqualityTracking.Integrations.Core
2+
{
3+
public static class AqualityConstants
4+
{
5+
public static readonly string SettingsFileName = "aqualityTracking.json";
6+
}
7+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
3+
namespace AqualityTracking.Integrations.Core
4+
{
5+
public class AqualityException : Exception
6+
{
7+
public AqualityException(string message) : base(message)
8+
{
9+
}
10+
}
11+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
6+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
7+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
8+
<Authors>aquality automation committers</Authors>
9+
<Company>aquality automation</Company>
10+
<Description>Aquality Tracking integration core for .NET test frameworks.</Description>
11+
<PackageDescription>Aquality Tracking integration core for .NET test frameworks.</PackageDescription>
12+
<PackageLicenseExpression></PackageLicenseExpression>
13+
<RepositoryUrl>https://github.com/aquality-automation/aquality-tracking-integrations-dotnet</RepositoryUrl>
14+
<RepositoryType>git</RepositoryType>
15+
<PackageTags>aquality-tracking</PackageTags>
16+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
17+
<Copyright>Copyright 2020 Aquality Automation</Copyright>
18+
<IsPackable>true</IsPackable>
19+
</PropertyGroup>
20+
21+
<ItemGroup>
22+
<None Include="..\..\..\LICENSE">
23+
<Pack>True</Pack>
24+
<PackagePath></PackagePath>
25+
</None>
26+
</ItemGroup>
27+
28+
<ItemGroup>
29+
<Content Include="Resources\aqualityTracking.Template.json">
30+
<Pack>True</Pack>
31+
</Content>
32+
</ItemGroup>
33+
34+
<ItemGroup>
35+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.4" />
36+
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
37+
</ItemGroup>
38+
39+
</Project>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
using AqualityTracking.Integrations.Core.Utilities;
2+
using Newtonsoft.Json.Linq;
3+
using System.ComponentModel;
4+
5+
namespace AqualityTracking.Integrations.Core.Configuration
6+
{
7+
public class AqualityConfiguration : IConfiguration
8+
{
9+
private bool enabled;
10+
private string host;
11+
private string token;
12+
private int projectId;
13+
private string executor;
14+
private string suiteName;
15+
private string buildName;
16+
private string environment;
17+
private string ciBuild;
18+
private bool debug;
19+
20+
public bool Enabled
21+
{
22+
get { return GetEnvValueOrDefault("aquality.enabled", enabled); }
23+
set { enabled = value; }
24+
}
25+
26+
public string Host
27+
{
28+
get { return GetEnvValueOrDefault("aquality.host", host); }
29+
set { host = value; }
30+
}
31+
32+
public string Token
33+
{
34+
get { return GetEnvValueOrDefault("aquality.token", token); }
35+
set { token = value; }
36+
}
37+
38+
public int ProjectId
39+
{
40+
get { return GetEnvValueOrDefault("aquality.projectId", projectId); }
41+
set { projectId = value; }
42+
}
43+
44+
public string Executor
45+
{
46+
get { return GetEnvValueOrDefault("aquality.executor", executor); }
47+
set { executor = value; }
48+
}
49+
50+
public string SuiteName
51+
{
52+
get { return GetEnvValueOrDefault("aquality.suiteName", suiteName); }
53+
set { suiteName = value; }
54+
}
55+
56+
public string BuildName
57+
{
58+
get { return GetEnvValueOrDefault("aquality.buildName", buildName); }
59+
set { buildName = value; }
60+
}
61+
62+
public string Environment
63+
{
64+
get { return GetEnvValueOrDefault("aquality.environment", environment); }
65+
set { environment = value; }
66+
}
67+
68+
public string CiBuild
69+
{
70+
get { return GetEnvValueOrDefault("aquality.ciBuild", ciBuild); }
71+
set { ciBuild = value; }
72+
}
73+
74+
public bool Debug
75+
{
76+
get { return GetEnvValueOrDefault("aquality.debug", debug); }
77+
set { debug = value; }
78+
}
79+
80+
private T GetEnvValueOrDefault<T>(string key, T defaultValue)
81+
{
82+
var envValue = EnvironmentReader.GetVariable(key);
83+
if (envValue != null)
84+
{
85+
return (T) TypeDescriptor.GetConverter(typeof(T)).ConvertFrom(envValue);
86+
}
87+
return defaultValue;
88+
}
89+
90+
public static AqualityConfiguration ParseFromJson(string json)
91+
{
92+
return JObject.Parse(json)?.ToObject<AqualityConfiguration>();
93+
}
94+
}
95+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace AqualityTracking.Integrations.Core.Configuration
2+
{
3+
public interface IConfiguration
4+
{
5+
bool Enabled { get; set; }
6+
7+
string Host { get; set; }
8+
9+
string Token { get; set; }
10+
11+
int ProjectId { get; set; }
12+
13+
string Executor { get; set; }
14+
15+
string SuiteName { get; set; }
16+
17+
string BuildName { get; set; }
18+
19+
string Environment { get; set; }
20+
21+
string CiBuild { get; set; }
22+
23+
bool Debug { get; set; }
24+
}
25+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using AqualityTracking.Integrations.Core.Models;
2+
3+
namespace AqualityTracking.Integrations.Core.Endpoints
4+
{
5+
public interface ISuiteEndpoints
6+
{
7+
/// <summary>
8+
/// Creates new suite or gets the existing one.
9+
/// </summary>
10+
/// <param name="name">Name of suite.</param>
11+
/// <returns>Instance of created or found Suite.</returns>
12+
Suite CreateSuite(string name);
13+
}
14+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using AqualityTracking.Integrations.Core.Models;
2+
using System.Collections.Generic;
3+
4+
namespace AqualityTracking.Integrations.Core.Endpoints
5+
{
6+
public interface ITestEndpoints
7+
{
8+
/// <summary>
9+
/// Creates new Test or updates and gets the existing one.
10+
/// Does not override the existing suites, adds a missing ones.
11+
/// </summary>
12+
/// <param name="name">Name of Test.</param>
13+
/// <param name="suites">List of Suites that Test belongs to.</param>
14+
/// <returns>Instance of new or updated Test.</returns>
15+
Test CreateOrUpdateTest(string name, IList<Suite> suites);
16+
}
17+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using AqualityTracking.Integrations.Core.Models;
2+
3+
namespace AqualityTracking.Integrations.Core.Endpoints
4+
{
5+
public interface ITestResultEndpoints
6+
{
7+
/// <summary>
8+
/// Starts new Test execution.
9+
/// </summary>
10+
/// <param name="testRunId">Id of current Test Run.</param>
11+
/// <param name="testId">Id of Test to execute.</param>
12+
/// <returns>Instance of started Test execution (Test Result).</returns>
13+
TestResult StartTestResult(int testRunId, int testId);
14+
15+
/// <summary>
16+
/// Sets Test Result.
17+
/// </summary>
18+
/// <param name="testResultId">Id of Test Result to finish.</param>
19+
/// <param name="finalResultId">Id of the result.</param>
20+
/// <param name="failReason">Reason of test failure. If not needed - pass null.</param>
21+
/// <returns>Instance of finished Test Result.</returns>
22+
TestResult FinishTestResult(int testResultId, FinalResultId finalResultId, string failReason);
23+
24+
/// <summary>
25+
/// Add attachment to Test Result.
26+
/// </summary>
27+
/// <param name="testResultId">Id of Test Result.</param>
28+
/// <param name="filePath">Path to attachment file.</param>
29+
void AddAttachment(int testResultId, string filePath);
30+
}
31+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using AqualityTracking.Integrations.Core.Models;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace AqualityTracking.Integrations.Core.Endpoints
7+
{
8+
public interface ITestRunEndpoints
9+
{
10+
/// <summary>
11+
/// Starts new Test Run.
12+
/// </summary>
13+
/// <param name="testSuiteId">Id of Test Suite which included in Test Run.</param>
14+
/// <param name="buildName">Name of current build.</param>
15+
/// <param name="environment">Name of execution environment.</param>
16+
/// <param name="executor">Name of author.</param>
17+
/// <param name="ciBuild">Link to the CI build of current Test Run.</param>
18+
/// <param name="debug">Debug (true) or regular (false) execution. If debug Test Run won't be present in Aquality Tracking.</param>
19+
/// <returns>Instance of started Test Run.</returns>
20+
TestRun StartTestRun(int testSuiteId, string buildName, string environment,
21+
string executor, string ciBuild, bool debug);
22+
23+
/// <summary>
24+
/// Finished Test Run.
25+
/// </summary>
26+
/// <param name="testRunId">Id of Test Run which should be finished.</param>
27+
/// <returns>Instance of finished Test Run.</returns>
28+
TestRun FinishTestRun(int testRunId);
29+
}
30+
}

0 commit comments

Comments
 (0)