Skip to content

Commit 997e34e

Browse files
authored
FE merge (#66)
2 parents bf440ea + 30b74ee commit 997e34e

File tree

263 files changed

+7180
-10585
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

263 files changed

+7180
-10585
lines changed

.editorconfig

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ csharp_style_conditional_delegate_call = true:suggestion
135135

136136
# Modifier preferences
137137
csharp_prefer_static_local_function = true:suggestion
138-
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent
138+
csharp_preferred_modifier_order = public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async:silent
139139

140140
# Code-block preferences
141141
csharp_prefer_braces = true:silent
@@ -191,7 +191,7 @@ dotnet_naming_symbols.non_field_members.required_modifiers =
191191

192192
dotnet_naming_symbols.private_method.applicable_kinds = method
193193
dotnet_naming_symbols.private_method.applicable_accessibilities = private
194-
dotnet_naming_symbols.private_method.required_modifiers =
194+
dotnet_naming_symbols.private_method.required_modifiers =
195195

196196
# Naming styles
197197

@@ -205,9 +205,9 @@ dotnet_naming_style.begins_with_i.required_suffix =
205205
dotnet_naming_style.begins_with_i.word_separator =
206206
dotnet_naming_style.begins_with_i.capitalization = pascal_case
207207

208-
dotnet_naming_style.camelcase.required_prefix =
209-
dotnet_naming_style.camelcase.required_suffix =
210-
dotnet_naming_style.camelcase.word_separator =
208+
dotnet_naming_style.camelcase.required_prefix =
209+
dotnet_naming_style.camelcase.required_suffix =
210+
dotnet_naming_style.camelcase.word_separator =
211211
dotnet_naming_style.camelcase.capitalization = camel_case
212212

213213

@@ -414,7 +414,7 @@ dotnet_diagnostic.CA1703.severity = warning
414414

415415
dotnet_diagnostic.CA1704.severity = warning
416416

417-
dotnet_diagnostic.CA1707.severity =suggestion
417+
dotnet_diagnostic.CA1707.severity = suggestion
418418

419419
dotnet_diagnostic.CA1708.severity = warning
420420

@@ -737,4 +737,4 @@ dotnet_diagnostic.SA1642.severity = none
737737
dotnet_diagnostic.SA1643.severity = none
738738

739739
dotnet_diagnostic.SA1652.severity = none
740-
dotnet_diagnostic.CA2007.severity=silent
740+
dotnet_diagnostic.CA2007.severity = silent

.github/workflows/github-monitor-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Setup dotnet
1717
uses: actions/setup-dotnet@v1
1818
with:
19-
dotnet-version: "6.0.x"
19+
dotnet-version: "8.0.x"
2020

2121
- name: "Run dotnet build"
2222
working-directory: github-monitor
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Grade Management New - build
2+
3+
on:
4+
push:
5+
paths:
6+
- "grade-management-new/**"
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 1
17+
18+
- name: Setup dotnet
19+
uses: actions/setup-dotnet@v1
20+
with:
21+
dotnet-version: "8.0.x"
22+
23+
- name: "Run dotnet build"
24+
working-directory: grade-management-new
25+
run: |
26+
dotnet build
27+
dotnet test
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<None Remove="SampleCallbacks\branch_create.json" />
11-
<None Remove="SampleCallbacks\comment_command.json" />
12-
<None Remove="SampleCallbacks\comment_delete.json" />
13-
<None Remove="SampleCallbacks\comment_edit.json" />
14-
<None Remove="SampleCallbacks\pr_open.json" />
15-
<None Remove="SampleCallbacks\pr_reviewcomment.json" />
16-
<None Remove="SampleCallbacks\pr_reviewrequested.json" />
17-
<None Remove="SampleCallbacks\workflow_run.json" />
10+
<None Remove="SampleCallbacks\branch_create.json"/>
11+
<None Remove="SampleCallbacks\comment_command.json"/>
12+
<None Remove="SampleCallbacks\comment_delete.json"/>
13+
<None Remove="SampleCallbacks\comment_edit.json"/>
14+
<None Remove="SampleCallbacks\pr_open.json"/>
15+
<None Remove="SampleCallbacks\pr_reviewcomment.json"/>
16+
<None Remove="SampleCallbacks\pr_reviewrequested.json"/>
17+
<None Remove="SampleCallbacks\workflow_run.json"/>
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<EmbeddedResource Include="SampleCallbacks\workflow_run.json" />
22-
<EmbeddedResource Include="SampleCallbacks\branch_create.json" />
23-
<EmbeddedResource Include="SampleCallbacks\comment_delete.json" />
24-
<EmbeddedResource Include="SampleCallbacks\comment_command.json" />
25-
<EmbeddedResource Include="SampleCallbacks\comment_edit.json" />
26-
<EmbeddedResource Include="SampleCallbacks\pr_reviewcomment.json" />
27-
<EmbeddedResource Include="SampleCallbacks\pr_reviewrequested.json" />
28-
<EmbeddedResource Include="SampleCallbacks\pr_open.json" />
21+
<EmbeddedResource Include="SampleCallbacks\workflow_run.json"/>
22+
<EmbeddedResource Include="SampleCallbacks\branch_create.json"/>
23+
<EmbeddedResource Include="SampleCallbacks\comment_delete.json"/>
24+
<EmbeddedResource Include="SampleCallbacks\comment_command.json"/>
25+
<EmbeddedResource Include="SampleCallbacks\comment_edit.json"/>
26+
<EmbeddedResource Include="SampleCallbacks\pr_reviewcomment.json"/>
27+
<EmbeddedResource Include="SampleCallbacks\pr_reviewrequested.json"/>
28+
<EmbeddedResource Include="SampleCallbacks\pr_open.json"/>
2929
</ItemGroup>
3030

3131
<ItemGroup>
32-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
33-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
34-
<PackageReference Include="Moq" Version="4.16.1" />
35-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
36-
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
32+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0"/>
33+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0"/>
34+
<PackageReference Include="Moq" Version="4.16.1"/>
35+
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8"/>
36+
<PackageReference Include="MSTest.TestFramework" Version="2.2.8"/>
3737
</ItemGroup>
3838

3939
<ItemGroup>
40-
<ProjectReference Include="..\Ahk.GitHub.Monitor\Ahk.GitHub.Monitor.csproj" />
40+
<ProjectReference Include="..\Ahk.GitHub.Monitor\Ahk.GitHub.Monitor.csproj"/>
4141
</ItemGroup>
4242

4343
</Project>
Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
using System.Threading.Tasks;
2+
using Ahk.GitHub.Monitor.Services.GitHubClientFactory;
23
using Microsoft.Extensions.Hosting;
34
using Microsoft.VisualStudio.TestTools.UnitTesting;
5+
using Microsoft.Azure.Functions.Worker;
6+
using Microsoft.Extensions.DependencyInjection;
47

5-
namespace Ahk.GitHub.Monitor.Tests.IntegrationTests
8+
namespace Ahk.GitHub.Monitor.Tests.IntegrationTests;
9+
10+
[TestClass]
11+
public class AppStartupTest
612
{
7-
[TestClass]
8-
public class AppStartupTest
13+
[TestMethod]
14+
public async Task AppStartupSucceeds()
915
{
10-
[TestMethod]
11-
public async Task AppStartupSucceeds()
12-
{
13-
var startup = new Startup();
14-
using var host = new HostBuilder()
15-
.ConfigureWebJobs(startup.Configure)
16-
.Build();
17-
await host.StartAsync();
18-
}
16+
IHost host = new HostBuilder()
17+
.ConfigureServices(services =>
18+
{
19+
services.AddSingleton<Services.IGitHubClientFactory, GitHubClientFactory>();
20+
})
21+
.Build();
22+
23+
await host.StartAsync();
24+
25+
await host.StopAsync();
1926
}
2027
}
Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,60 @@
11
using System.Threading.Tasks;
2+
using Ahk.GitHub.Monitor.Services.EventDispatch;
23
using Microsoft.AspNetCore.Http;
34
using Microsoft.AspNetCore.Mvc;
5+
using Microsoft.Extensions.Logging;
46
using Microsoft.Extensions.Logging.Abstractions;
57
using Microsoft.Extensions.Options;
68
using Microsoft.VisualStudio.TestTools.UnitTesting;
79
using Moq;
810

9-
namespace Ahk.GitHub.Monitor.Tests.IntegrationTests
11+
namespace Ahk.GitHub.Monitor.Tests.IntegrationTests;
12+
13+
[TestClass]
14+
public class FunctionInvokeTest
1015
{
11-
[TestClass]
12-
public class FunctionInvokeTest
16+
[TestMethod]
17+
public async Task NoAppConfigsReturnsError()
1318
{
14-
[TestMethod]
15-
public async Task NoAppConfigsReturnsError()
16-
{
17-
var eds = new Mock<Services.IEventDispatchService>();
18-
var func = new GitHubMonitorFunction(eds.Object, Options.Create(new GitHubMonitorConfig()));
19+
var log = new Mock<ILogger<GitHubMonitorFunction>>();
20+
var eds = new Mock<IEventDispatchService>();
21+
var func = new GitHubMonitorFunction(eds.Object, Options.Create(new GitHubMonitorConfig()), log.Object);
1922

20-
var resp = await func.InvokeAndGetResponseAs<ObjectResult>(req => { });
23+
ObjectResult resp = await func.InvokeAndGetResponseAs<ObjectResult>(req => { });
2124

22-
Assert.AreEqual(StatusCodes.Status500InternalServerError, resp.StatusCode);
23-
eds.Verify(s => s.Process(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<WebhookResult>(), NullLogger.Instance), Times.Never());
24-
}
25+
Assert.AreEqual(StatusCodes.Status500InternalServerError, resp.StatusCode);
26+
eds.Verify(
27+
s => s.Process(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<WebhookResult>(), NullLogger.Instance),
28+
Times.Never());
29+
}
2530

26-
[TestMethod]
27-
public async Task MissingGitHubEventHeaderReturnsError()
28-
{
29-
var eds = new Mock<Services.IEventDispatchService>();
30-
var func = FunctionBuilder.Create(eds.Object);
31+
[TestMethod]
32+
public async Task MissingGitHubEventHeaderReturnsError()
33+
{
34+
var eds = new Mock<IEventDispatchService>();
35+
GitHubMonitorFunction func = FunctionBuilder.Create(eds.Object);
3136

32-
var resp = await func.InvokeAndGetResponseAs<ObjectResult>(req => req.Headers.Add("X-Hub-Signature-256", "dummy"));
37+
ObjectResult resp =
38+
await func.InvokeAndGetResponseAs<ObjectResult>(req => req.Headers.Add("X-Hub-Signature-256", "dummy"));
3339

34-
Assert.AreEqual(StatusCodes.Status400BadRequest, resp.StatusCode);
35-
eds.Verify(s => s.Process(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<WebhookResult>(), NullLogger.Instance), Times.Never());
36-
}
40+
Assert.AreEqual(StatusCodes.Status400BadRequest, resp.StatusCode);
41+
eds.Verify(
42+
s => s.Process(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<WebhookResult>(), NullLogger.Instance),
43+
Times.Never());
44+
}
3745

38-
[TestMethod]
39-
public async Task MissingGitHubSignatureHeaderReturnsError()
40-
{
41-
var eds = new Mock<Services.IEventDispatchService>();
42-
var func = FunctionBuilder.Create(eds.Object);
46+
[TestMethod]
47+
public async Task MissingGitHubSignatureHeaderReturnsError()
48+
{
49+
var eds = new Mock<IEventDispatchService>();
50+
GitHubMonitorFunction func = FunctionBuilder.Create(eds.Object);
4351

44-
var resp = await func.InvokeAndGetResponseAs<ObjectResult>(req => req.Headers.Add("X-GitHub-Event", "dummy"));
52+
ObjectResult resp =
53+
await func.InvokeAndGetResponseAs<ObjectResult>(req => req.Headers.Add("X-GitHub-Event", "dummy"));
4554

46-
Assert.AreEqual(StatusCodes.Status400BadRequest, resp.StatusCode);
47-
eds.Verify(s => s.Process(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<WebhookResult>(), NullLogger.Instance), Times.Never());
48-
}
55+
Assert.AreEqual(StatusCodes.Status400BadRequest, resp.StatusCode);
56+
eds.Verify(
57+
s => s.Process(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<WebhookResult>(), NullLogger.Instance),
58+
Times.Never());
4959
}
5060
}
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1+
using Ahk.GitHub.Monitor.Services.EventDispatch;
2+
using Microsoft.Extensions.Logging;
13
using Microsoft.Extensions.Options;
24
using Moq;
35

4-
namespace Ahk.GitHub.Monitor.Tests.IntegrationTests
6+
namespace Ahk.GitHub.Monitor.Tests.IntegrationTests;
7+
8+
internal static class FunctionBuilder
59
{
6-
internal static class FunctionBuilder
10+
public static readonly GitHubMonitorConfig AppConfig = new()
711
{
8-
public static readonly GitHubMonitorConfig AppConfig = new GitHubMonitorConfig()
9-
{
10-
GitHubAppId = "appid",
11-
GitHubAppPrivateKey = "appprivatekey",
12-
GitHubWebhookSecret = "webhooksecret",
13-
};
12+
GitHubAppId = "appid", GitHubAppPrivateKey = "appprivatekey", GitHubWebhookSecret = "webhooksecret"
13+
};
1414

15-
public static GitHubMonitorFunction Create(Services.IEventDispatchService dispatchService = null)
16-
=> new GitHubMonitorFunction(dispatchService ?? new Mock<Services.IEventDispatchService>().Object, Options.Create(AppConfig));
17-
}
15+
public static GitHubMonitorFunction Create(IEventDispatchService dispatchService = null)
16+
=> new(dispatchService ?? new Mock<IEventDispatchService>().Object,
17+
Options.Create(AppConfig),
18+
new Mock<ILogger<GitHubMonitorFunction>>().Object);
1819
}

0 commit comments

Comments
 (0)