Skip to content

Commit 9e66eea

Browse files
committed
Adding editorconfig + CR changes
1 parent 2819e3e commit 9e66eea

File tree

10 files changed

+879
-853
lines changed

10 files changed

+879
-853
lines changed

.editorconfig

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
trim_trailing_whitespace = true
7+
8+
[*.csproj]
9+
indent_size = 2
10+
11+
[*.cs]
12+
dotnet_sort_system_directives_first = true
13+
dotnet_style_predefined_type_for_locals_parameters_members = true
14+
dotnet_style_predefined_type_for_member_access = false

CICD.Tools.MSTeamsWorkflowWebhookCard.LibTests/CICD.Tools.MSTeamsWorkflowWebhookCard.LibTests.csproj

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
32
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
3+
<TargetFrameworks>net48;net8.0</TargetFrameworks>
4+
<ImplicitUsings>disable</ImplicitUsings>
5+
<Nullable>disable</Nullable>
76

87
<IsPackable>false</IsPackable>
98
<IsTestProject>true</IsTestProject>
109
</PropertyGroup>
1110

1211
<ItemGroup>
1312
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
15-
<PackageReference Include="MSTest.TestAdapter" Version="3.0.4" />
16-
<PackageReference Include="MSTest.TestFramework" Version="3.0.4" />
17-
<PackageReference Include="coverlet.collector" Version="6.0.0" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
14+
<PackageReference Include="MSTest.TestAdapter" Version="3.5.0" />
15+
<PackageReference Include="MSTest.TestFramework" Version="3.5.0" />
16+
<PackageReference Include="coverlet.collector" Version="6.0.2">
17+
<PrivateAssets>all</PrivateAssets>
18+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
19+
</PackageReference>
1820
<PackageReference Include="RichardSzalay.MockHttp" Version="7.0.0" />
1921
<PackageReference Include="Serilog" Version="4.0.0" />
2022
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,93 @@
1-
namespace Skyline.DataMiner.CICD.Tools.MSTeamsWorkflowWebhookCard.Lib.Tests
1+
namespace CICD.Tools.MSTeamsWorkflowWebhookCard.LibTests
22
{
3-
using System.Text;
4-
5-
using Microsoft.Extensions.Logging;
6-
using Microsoft.VisualStudio.TestTools.UnitTesting;
7-
8-
using RichardSzalay.MockHttp;
9-
10-
using Serilog;
11-
12-
[TestClass()]
13-
public class CicdCardTests
14-
{
15-
[TestMethod()]
16-
public async Task SendAsyncTest_TestFormatIsValidForTeams()
17-
{
18-
// Arrange
19-
var mockHttp = new MockHttpMessageHandler();
20-
21-
var logConfig = new LoggerConfiguration().WriteTo.Console();
22-
logConfig.MinimumLevel.Is(Serilog.Events.LogEventLevel.Debug);
23-
var seriLog = logConfig.CreateLogger();
24-
25-
using var loggerFactory = LoggerFactory.Create(builder => builder.AddSerilog(seriLog));
26-
var logger = loggerFactory.CreateLogger("Skyline.DataMiner.CICD.Tools.MSTeamsWorkflowWebhookCard");
27-
28-
string name = "TestPipeline";
29-
CicdResult result = CicdResult.Success;
30-
string details = "Some Details";
31-
string pathToBuild = "https://skyline.be/skyline/about";
32-
string iconOfService = "https://skyline.be/skylicons/duotone/SkylineLogo_Duo_Light.png";
33-
string url = "https://skyline.be/";
34-
35-
var matcher = new TeamsAdaptiveCardMatcher(logger);
36-
var responseContent = new StringContent("OK", Encoding.UTF8, "application/string");
37-
mockHttp.When(HttpMethod.Post, url).With(matcher).Respond(System.Net.HttpStatusCode.OK, responseContent);
38-
39-
using var client = mockHttp.ToHttpClient();
40-
41-
// Act
42-
var card = new CicdCard(logger, client);
43-
card.ApplyConfiguration(name, result, details, pathToBuild, iconOfService);
44-
await card.SendAsync(url);
45-
46-
// Assert
47-
mockHttp.VerifyNoOutstandingExpectation();
48-
}
49-
50-
51-
[TestMethod(), Ignore]
52-
public async Task SendAsyncTest_IntegrationTest()
53-
{
54-
// Arrange
55-
var logConfig = new LoggerConfiguration().WriteTo.Console();
56-
logConfig.MinimumLevel.Is(Serilog.Events.LogEventLevel.Debug);
57-
var seriLog = logConfig.CreateLogger();
58-
59-
using var loggerFactory = LoggerFactory.Create(builder => builder.AddSerilog(seriLog));
60-
var logger = loggerFactory.CreateLogger("Skyline.DataMiner.CICD.Tools.MSTeamsWorkflowWebhookCard");
61-
62-
string name = "IntegrationTestPipeline";
63-
CicdResult result = CicdResult.Success;
64-
string details = "This is an integration test running from the testbattery. \r\n This should be on a second line!";
65-
string pathToBuild = "https://github.com/SkylineCommunications/Skyline.DataMiner.CICD.Tools.MSTeamsWorkflowWebhookCard";
66-
string iconOfService = "https://skyline.be/skylicons/duotone/SkylineLogo_Duo_Light.png";
67-
string url = "EnterWebHookFromTeamsChannelHere";
68-
69-
using HttpClient client = new HttpClient();
70-
71-
// Act
72-
var card = new CicdCard(logger, client);
73-
card.ApplyConfiguration(name, result, details, pathToBuild, iconOfService);
74-
await card.SendAsync(url);
75-
76-
// Assert
77-
78-
// Manual Verification of content as this is Graphical Design.
79-
Assert.IsTrue(true);
80-
}
81-
}
3+
using System.Net.Http;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
using CICD.Tools.MSTeamsWorkflowWebhookCard.LibTests.MatchTeamsRequirement;
8+
9+
using Microsoft.Extensions.Logging;
10+
using Microsoft.VisualStudio.TestTools.UnitTesting;
11+
12+
using RichardSzalay.MockHttp;
13+
14+
using Serilog;
15+
16+
using Skyline.DataMiner.CICD.Tools.MSTeamsWorkflowWebhookCard.Lib;
17+
18+
[TestClass]
19+
public class CicdCardTests
20+
{
21+
[TestMethod]
22+
public async Task SendAsyncTest_TestFormatIsValidForTeams()
23+
{
24+
// Arrange
25+
var mockHttp = new MockHttpMessageHandler();
26+
27+
var logConfig = new LoggerConfiguration().WriteTo.Console();
28+
logConfig.MinimumLevel.Is(Serilog.Events.LogEventLevel.Debug);
29+
var seriLog = logConfig.CreateLogger();
30+
31+
using (var loggerFactory = LoggerFactory.Create(builder => builder.AddSerilog(seriLog)))
32+
{
33+
var logger = loggerFactory.CreateLogger("Skyline.DataMiner.CICD.Tools.MSTeamsWorkflowWebhookCard");
34+
35+
const string name = "TestPipeline";
36+
const CicdResult result = CicdResult.Success;
37+
const string details = "Some Details";
38+
const string pathToBuild = "https://skyline.be/skyline/about";
39+
const string iconOfService = "https://skyline.be/skylicons/duotone/SkylineLogo_Duo_Light.png";
40+
const string url = "https://skyline.be/";
41+
42+
var matcher = new TeamsAdaptiveCardMatcher(logger);
43+
var responseContent = new StringContent("OK", Encoding.UTF8, "application/string");
44+
mockHttp.When(HttpMethod.Post, url).With(matcher).Respond(System.Net.HttpStatusCode.OK, responseContent);
45+
46+
using (var client = mockHttp.ToHttpClient())
47+
{
48+
// Act
49+
var card = new CicdCard(logger, client);
50+
card.ApplyConfiguration(name, result, details, pathToBuild, iconOfService);
51+
await card.SendAsync(url);
52+
53+
// Assert
54+
mockHttp.VerifyNoOutstandingExpectation();
55+
}
56+
}
57+
}
58+
59+
[TestMethod, Ignore]
60+
public async Task SendAsyncTest_IntegrationTest()
61+
{
62+
// Arrange
63+
var logConfig = new LoggerConfiguration().WriteTo.Console();
64+
logConfig.MinimumLevel.Is(Serilog.Events.LogEventLevel.Debug);
65+
var seriLog = logConfig.CreateLogger();
66+
67+
using (var loggerFactory = LoggerFactory.Create(builder => builder.AddSerilog(seriLog)))
68+
{
69+
var logger = loggerFactory.CreateLogger("Skyline.DataMiner.CICD.Tools.MSTeamsWorkflowWebhookCard");
70+
71+
const string name = "IntegrationTestPipeline";
72+
const CicdResult result = CicdResult.Success;
73+
const string details = "This is an integration test running from the testbattery. \r\n This should be on a second line!";
74+
const string pathToBuild = "https://github.com/SkylineCommunications/Skyline.DataMiner.CICD.Tools.MSTeamsWorkflowWebhookCard";
75+
const string iconOfService = "https://skyline.be/skylicons/duotone/SkylineLogo_Duo_Light.png";
76+
const string url = "EnterWebHookFromTeamsChannelHere";
77+
78+
using (HttpClient client = new HttpClient())
79+
{
80+
// Act
81+
var card = new CicdCard(logger, client);
82+
card.ApplyConfiguration(name, result, details, pathToBuild, iconOfService);
83+
await card.SendAsync(url);
84+
85+
// Assert
86+
87+
// Manual Verification of content as this is Graphical Design.
88+
Assert.IsTrue(true);
89+
}
90+
}
91+
}
92+
}
8293
}

0 commit comments

Comments
 (0)