Skip to content

Commit 05e6dfc

Browse files
Removing JSON serialization files from coverage
1 parent 5a90d6c commit 05e6dfc

File tree

8 files changed

+36
-16
lines changed

8 files changed

+36
-16
lines changed

src/Nullinside.Api.Common.AspNetCore/Middleware/BasicAuthorizationRequirement.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
13
using Microsoft.AspNetCore.Authorization;
24

35
namespace Nullinside.Api.Common.AspNetCore.Middleware;
46

57
/// <summary>
68
/// Represents a requirement where a user is expected to have one role.
79
/// </summary>
10+
[ExcludeFromCodeCoverage]
811
public class BasicAuthorizationRequirement : IAuthorizationRequirement {
912
/// <summary>
1013
/// Initializes a new instance of the <see cref="BasicAuthorizationRequirement" /> class.

src/Nullinside.Api.Common/Desktop/GithubLatestReleaseJson.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
namespace Nullinside.Api.Common.Desktop;
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace Nullinside.Api.Common.Desktop;
24

35
/// <summary>
46
/// The response information from GitHub's API.
57
/// </summary>
8+
[ExcludeFromCodeCoverage]
69
public class GithubLatestReleaseJson {
710
/// <summary>
811
/// The url of the resource.

src/Nullinside.Api.Common/Docker/Support/DockerComposeLsOutput.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
13
namespace Nullinside.Api.Common.Docker.Support;
24

35
/// <summary>
46
/// The `docker compose ls --format 'json'` output.
57
/// </summary>
8+
[ExcludeFromCodeCoverage]
69
public class DockerComposeLsOutput {
710
/// <summary>
811
/// The name of the docker compose project.

src/Nullinside.Api.Common/Docker/Support/DockerResource.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
13
namespace Nullinside.Api.Common.Docker.Support;
24

35
/// <summary>
46
/// A docker resource representing either a docker compose project
57
/// or a single docker container.
68
/// </summary>
9+
[ExcludeFromCodeCoverage]
710
public class DockerResource {
811
/// <summary>
912
/// Initializes a new instance of the <see cref="DockerResource" /> class.

src/Nullinside.Api.Common/Exceptions/RetryException.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
namespace Nullinside.Api.Common.Exceptions;
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace Nullinside.Api.Common.Exceptions;
24

35
/// <summary>
46
/// An exception thrown if an action continues to fail after retrying.
57
/// </summary>
8+
[ExcludeFromCodeCoverage]
69
public class RetryException : Exception {
710
/// <summary>
811
/// Initializes a new instance of the <see cref="RetryException" /> class.

src/Nullinside.Api.Common/Twitch/Json/TwitchModeratedChannelsResponse.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
namespace Nullinside.Api.Common.Twitch.Json;
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace Nullinside.Api.Common.Twitch.Json;
24

35
/// <summary>
46
/// The response to a query for what channels a user is moderator for.
57
/// </summary>
8+
[ExcludeFromCodeCoverage]
69
public class TwitchModeratedChannelsResponse {
710
/// <summary>
811
/// The list of channels the user moderates for.
@@ -18,6 +21,7 @@ public class TwitchModeratedChannelsResponse {
1821
/// <summary>
1922
/// A channel the user moderates.
2023
/// </summary>
24+
[ExcludeFromCodeCoverage]
2125
public class TwitchModeratedChannel {
2226
/// <summary>
2327
/// The twitch id.
@@ -38,6 +42,7 @@ public class TwitchModeratedChannel {
3842
/// <summary>
3943
/// Pagination information.
4044
/// </summary>
45+
[ExcludeFromCodeCoverage]
4146
public class Pagination {
4247
/// <summary>
4348
/// The cursor to pass to "after" for pagination.

src/Nullinside.Api.Tests/Nullinside.Api/Controllers/DockerControllerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public async Task OnOffComposeProjectsWork() {
106106
Assert.That(obj.StatusCode, Is.EqualTo(200));
107107

108108
// Ensure we called the 3rd party API with a value of "Good" to turn on a compose.
109-
bool deployments = (bool)obj.Value;
109+
bool deployments = (bool)obj.Value!;
110110
Assert.That(deployments, Is.True);
111111
}
112112

@@ -137,7 +137,7 @@ public async Task OnOffContainerWork() {
137137
Assert.That(obj.StatusCode, Is.EqualTo(200));
138138

139139
// Ensure we called the 3rd party API with a value of "Good" to turn on a container.
140-
bool deployments = (bool)obj.Value;
140+
bool deployments = (bool)obj.Value!;
141141
Assert.That(deployments, Is.True);
142142
}
143143

src/Nullinside.Api.Tests/Nullinside.Api/Controllers/UserControllerTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public async Task PerformGoogleLoginExisting() {
7272
Assert.That(this._db.Users.Count(), Is.EqualTo(1));
7373

7474
// We should have saved the token in the existing user's database.
75-
Assert.That(obj.Url.EndsWith(this._db.Users.First().Token), Is.True);
75+
Assert.That(obj.Url.EndsWith(this._db.Users.First().Token!), Is.True);
7676
}
7777

7878
/// <summary>
@@ -92,15 +92,15 @@ public async Task PerformGoogleLoginNewUser() {
9292
Assert.That(this._db.Users.Count(), Is.EqualTo(1));
9393

9494
// We should have saved the token in the existing user's database.
95-
Assert.That(obj.Url.EndsWith(this._db.Users.First().Token), Is.True);
95+
Assert.That(obj.Url.EndsWith(this._db.Users.First().Token!), Is.True);
9696
}
9797

9898
/// <summary>
9999
/// Tests that we handle DB errors correctly in the google login.
100100
/// </summary>
101101
[Test]
102102
public async Task GoToErrorOnDbException() {
103-
this._db.Users = null;
103+
this._db.Users = null!;
104104

105105
// Make the call and ensure it's successful.
106106
var controller = new TestableUserController(_configuration, _db);
@@ -157,7 +157,7 @@ public async Task PerformTwitchLoginExisting() {
157157
Assert.That(this._db.Users.Count(), Is.EqualTo(1));
158158

159159
// We should have saved the token in the existing user's database.
160-
Assert.That(obj.Url.EndsWith(this._db.Users.First().Token), Is.True);
160+
Assert.That(obj.Url.EndsWith(this._db.Users.First().Token!), Is.True);
161161
}
162162

163163
/// <summary>
@@ -184,7 +184,7 @@ public async Task PerformTwitchLoginNewUser() {
184184
Assert.That(this._db.Users.Count(), Is.EqualTo(1));
185185

186186
// We should have saved the token in the existing user's database.
187-
Assert.That(obj.Url.EndsWith(this._db.Users.First().Token), Is.True);
187+
Assert.That(obj.Url.EndsWith(this._db.Users.First().Token!), Is.True);
188188
}
189189

190190
/// <summary>
@@ -226,7 +226,7 @@ public async Task PerformTwitchLoginWithNoEmailAccount() {
226226
/// </summary>
227227
[Test]
228228
public async Task PerformTwitchLoginDbFailure() {
229-
_db.Users = null;
229+
_db.Users = null!;
230230

231231
// Tells us twitch parsed the code successfully.
232232
_twitchApi.Setup(a => a.CreateAccessToken(It.IsAny<string>(), It.IsAny<CancellationToken>()))
@@ -265,9 +265,9 @@ public void GetRoles() {
265265
Assert.That(obj.StatusCode, Is.EqualTo(200));
266266

267267
// Ensure we got the role we put in.
268-
var roles = obj.Value.GetType().GetProperty("roles").GetValue(obj.Value) as IEnumerable<string>;
269-
Assert.That(roles.Count(), Is.EqualTo(1));
270-
Assert.That(roles.First(), Is.EqualTo("candy"));
268+
var roles = obj.Value!.GetType().GetProperty("roles")!.GetValue(obj.Value) as IEnumerable<string>;
269+
Assert.That(roles!.Count(), Is.EqualTo(1));
270+
Assert.That(roles!.First(), Is.EqualTo("candy"));
271271
}
272272

273273
/// <summary>
@@ -303,7 +303,7 @@ public async Task ValidateFailWithoutToken() {
303303
/// </summary>
304304
[Test]
305305
public async Task ValidateFailOnDbFailure() {
306-
this._db.Users = null;
306+
this._db.Users = null!;
307307

308308
// Make the call and ensure it fails.
309309
var controller = new TestableUserController(_configuration, _db);
@@ -329,7 +329,7 @@ public TestableUserController(IConfiguration configuration, INullinsideContext d
329329
/// <inheritdoc />
330330
protected override Task<GoogleJsonWebSignature.Payload?> GenerateUserObject(GoogleOpenIdToken creds) {
331331
if (null != Email) {
332-
return Task.FromResult(new GoogleJsonWebSignature.Payload() { Email = Email });
332+
return Task.FromResult<GoogleJsonWebSignature.Payload?>(new GoogleJsonWebSignature.Payload() { Email = Email });
333333
}
334334

335335
return Task.FromResult<GoogleJsonWebSignature.Payload?>(null);

0 commit comments

Comments
 (0)