Skip to content

Commit 3c76d8f

Browse files
authored
Merge branch 'main' into dependabot/nuget/ManagedCode.Communication.Tests/Microsoft.AspNetCore.SignalR.Client-9.0.8
2 parents c37f332 + 905fb5e commit 3c76d8f

File tree

12 files changed

+120
-82
lines changed

12 files changed

+120
-82
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@v4
19+
uses: actions/checkout@v5
2020

2121
- name: Setup .NET
2222
uses: actions/setup-dotnet@v4

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828
steps:
2929
- name: Checkout repository
30-
uses: actions/checkout@v4
30+
uses: actions/checkout@v5
3131

3232
- name: Setup .NET
3333
uses: actions/setup-dotnet@v4

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
steps:
2020
- name: Checkout
21-
uses: actions/checkout@v4
21+
uses: actions/checkout@v5
2222

2323
- name: Setup .NET
2424
uses: actions/setup-dotnet@v4
@@ -63,7 +63,7 @@ jobs:
6363

6464
steps:
6565
- name: Checkout
66-
uses: actions/checkout@v4
66+
uses: actions/checkout@v5
6767

6868
- name: Download artifacts
6969
uses: actions/download-artifact@v4
@@ -122,7 +122,7 @@ jobs:
122122

123123
steps:
124124
- name: Checkout
125-
uses: actions/checkout@v4
125+
uses: actions/checkout@v5
126126
with:
127127
fetch-depth: 0
128128
token: ${{ secrets.GITHUB_TOKEN }}

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
<RepositoryUrl>https://github.com/managedcode/Communication</RepositoryUrl>
2727
<PackageProjectUrl>https://github.com/managedcode/Communication</PackageProjectUrl>
2828
<Product>Managed Code - Communication</Product>
29-
<Version>9.5.2</Version>
30-
<PackageVersion>9.5.2</PackageVersion>
29+
<Version>9.6.1</Version>
30+
<PackageVersion>9.6.1</PackageVersion>
3131

3232
</PropertyGroup>
3333
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">

ManagedCode.Communication.Tests/ManagedCode.Communication.Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.7"/>
2929
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1"/>
3030
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
31-
<PackageReference Include="System.Text.Json" Version="9.0.7"/>
32-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.7"/>
31+
<PackageReference Include="System.Text.Json" Version="9.0.8"/>
32+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.8"/>
3333
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="9.0.8"/>
34-
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="9.0.7"/>
34+
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="9.0.8"/>
3535
<PackageReference Include="xunit" Version="2.9.3"/>
3636
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.3">
3737
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

ManagedCode.Communication.Tests/Results/CollectionResultTests.cs

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public void Empty_ShouldCreateEmptyResult()
153153
.BeEmpty();
154154
result.PageNumber
155155
.Should()
156-
.Be(1);
156+
.Be(0);
157157
result.PageSize
158158
.Should()
159159
.Be(0);
@@ -171,33 +171,6 @@ public void Empty_ShouldCreateEmptyResult()
171171
.BeTrue();
172172
}
173173

174-
[Fact]
175-
public void Empty_WithPaging_ShouldCreateEmptyResultWithPaging()
176-
{
177-
// Act
178-
var result = CollectionResult<string>.Empty(pageNumber: 2, pageSize: 10);
179-
180-
// Assert
181-
result.IsSuccess
182-
.Should()
183-
.BeTrue();
184-
result.Collection
185-
.Should()
186-
.BeEmpty();
187-
result.PageNumber
188-
.Should()
189-
.Be(2);
190-
result.PageSize
191-
.Should()
192-
.Be(10);
193-
result.TotalItems
194-
.Should()
195-
.Be(0);
196-
result.TotalPages
197-
.Should()
198-
.Be(0);
199-
}
200-
201174
[Fact]
202175
public void Fail_WithMessage_ShouldCreateFailedResult()
203176
{
@@ -477,10 +450,10 @@ public void ThrowIfFail_WithValidationFailure_ShouldThrowWithValidationDetails()
477450

478451
exception.Problem.Title.Should().Be("Validation Failed");
479452
exception.Problem.StatusCode.Should().Be(400);
480-
453+
481454
var validationErrors = exception.Problem.GetValidationErrors();
482455
validationErrors.Should().NotBeNull();
483456
validationErrors!["filter"].Should().Contain("Invalid filter format");
484457
validationErrors!["pageSize"].Should().Contain("Page size must be between 1 and 100");
485458
}
486-
}
459+
}

ManagedCode.Communication.Tests/Serialization/SerializationTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void Problem_WithValidationErrors_ShouldSerializeAndDeserialize()
6060
deserialized!.Type.Should().Be(ProblemConstants.Types.ValidationFailed);
6161
deserialized.Title.Should().Be(ProblemConstants.Titles.ValidationFailed);
6262
deserialized.StatusCode.Should().Be(400);
63-
63+
6464
var errors = deserialized.GetValidationErrors();
6565
errors.Should().NotBeNull();
6666
errors!["email"].Should().Contain("Invalid format");
@@ -220,7 +220,7 @@ public void CollectionResult_Empty_ShouldSerializeAndDeserialize()
220220
// Assert
221221
deserialized.IsSuccess.Should().BeTrue();
222222
deserialized.Collection.Should().BeEmpty();
223-
deserialized.PageNumber.Should().Be(1);
223+
deserialized.PageNumber.Should().Be(0);
224224
deserialized.PageSize.Should().Be(0);
225225
deserialized.TotalItems.Should().Be(0);
226226
}
@@ -437,4 +437,4 @@ private class TestModel
437437
public string? Name { get; set; }
438438
public string[]? Tags { get; set; }
439439
}
440-
}
440+
}

ManagedCode.Communication/CollectionResultT/CollectionResult.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,5 @@ public static CollectionResult<T> Empty()
173173
return Create(true, [], 0, 0, 0);
174174
}
175175

176-
/// <summary>
177-
/// Creates an empty collection result with paging information.
178-
/// </summary>
179-
public static CollectionResult<T> Empty()
180-
{
181-
return Create(true, [], 0, 0, 0);
182-
}
183-
184176
#endregion
185177
}

ManagedCode.Communication/CollectionResultT/CollectionResultT.Fail.cs

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ public static CollectionResult<T> Fail(string title)
3333
var problem = Problem.Create(title, title, (int)HttpStatusCode.InternalServerError);
3434
return Create(false, default, 0, 0, 0, problem);
3535
}
36-
36+
3737
public static CollectionResult<T> Fail(string title, string detail)
3838
{
3939
var problem = Problem.Create(title, detail);
4040
return Create(false, default, 0, 0, 0, problem);
4141
}
42-
42+
4343
public static CollectionResult<T> Fail(string title, string detail, HttpStatusCode status)
4444
{
4545
var problem = Problem.Create(title, detail, (int)status);
@@ -50,7 +50,7 @@ public static CollectionResult<T> Fail(Exception exception)
5050
{
5151
return new CollectionResult<T>(false, default, 0, 0, 0, Problem.Create(exception, (int)HttpStatusCode.InternalServerError));
5252
}
53-
53+
5454
public static CollectionResult<T> Fail(Exception exception, HttpStatusCode status)
5555
{
5656
return new CollectionResult<T>(false, default, 0, 0, 0, Problem.Create(exception, (int)status));
@@ -61,6 +61,26 @@ public static CollectionResult<T> FailValidation(params (string field, string me
6161
return new CollectionResult<T>(false, default, 0, 0, 0, Problem.Validation(errors));
6262
}
6363

64+
public static CollectionResult<T> FailBadRequest()
65+
{
66+
var problem = Problem.Create(
67+
ProblemConstants.Titles.BadRequest,
68+
ProblemConstants.Messages.BadRequest,
69+
(int)HttpStatusCode.BadRequest);
70+
71+
return Create(false, default, 0, 0, 0, problem);
72+
}
73+
74+
public static CollectionResult<T> FailBadRequest(string detail)
75+
{
76+
var problem = Problem.Create(
77+
ProblemConstants.Titles.BadRequest,
78+
detail,
79+
(int)HttpStatusCode.BadRequest);
80+
81+
return Create(false, default, 0, 0, 0, problem);
82+
}
83+
6484
public static CollectionResult<T> FailUnauthorized()
6585
{
6686
var problem = Problem.Create(
@@ -70,7 +90,7 @@ public static CollectionResult<T> FailUnauthorized()
7090

7191
return Create(false, default, 0, 0, 0, problem);
7292
}
73-
93+
7494
public static CollectionResult<T> FailUnauthorized(string detail)
7595
{
7696
var problem = Problem.Create(
@@ -90,7 +110,7 @@ public static CollectionResult<T> FailForbidden()
90110

91111
return Create(false, default, 0, 0, 0, problem);
92112
}
93-
113+
94114
public static CollectionResult<T> FailForbidden(string detail)
95115
{
96116
var problem = Problem.Create(
@@ -110,7 +130,7 @@ public static CollectionResult<T> FailNotFound()
110130

111131
return Create(false, default, 0, 0, 0, problem);
112132
}
113-
133+
114134
public static CollectionResult<T> FailNotFound(string detail)
115135
{
116136
var problem = Problem.Create(
@@ -125,7 +145,7 @@ public static CollectionResult<T> Fail<TEnum>(TEnum errorCode) where TEnum : Enu
125145
{
126146
return new CollectionResult<T>(false, default, 0, 0, 0, Problem.Create(errorCode));
127147
}
128-
148+
129149
public static CollectionResult<T> Fail<TEnum>(TEnum errorCode, string detail) where TEnum : Enum
130150
{
131151
return new CollectionResult<T>(false, default, 0, 0, 0, Problem.Create(errorCode, detail));
@@ -135,9 +155,9 @@ public static CollectionResult<T> Fail<TEnum>(TEnum errorCode, HttpStatusCode st
135155
{
136156
return new CollectionResult<T>(false, default, 0, 0, 0, Problem.Create(errorCode, errorCode.ToString(), (int)status));
137157
}
138-
158+
139159
public static CollectionResult<T> Fail<TEnum>(TEnum errorCode, string detail, HttpStatusCode status) where TEnum : Enum
140160
{
141161
return new CollectionResult<T>(false, default, 0, 0, 0, Problem.Create(errorCode, detail, (int)status));
142162
}
143-
}
163+
}

ManagedCode.Communication/Constants/ProblemConstants.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public static class Titles
2929
/// </summary>
3030
public static class Messages
3131
{
32+
public const string BadRequest = "The request could not be understood by the server due to malformed syntax.";
3233
public const string UnauthorizedAccess = "Authentication is required to access this resource.";
3334
public const string ForbiddenAccess = "You do not have permission to access this resource.";
3435
public const string ResourceNotFound = "The requested resource was not found.";
@@ -44,7 +45,7 @@ public static class Types
4445
{
4546
public const string AboutBlank = "about:blank";
4647
public const string ValidationFailed = "https://tools.ietf.org/html/rfc7231#section-6.5.1";
47-
48+
4849
public static string HttpStatus(int statusCode) => $"https://httpstatuses.io/{statusCode}";
4950
}
5051

@@ -83,7 +84,7 @@ public static class ExtensionKeys
8384
/// </summary>
8485
public const string OriginalExceptionType = "originalExceptionType";
8586
}
86-
87+
8788
/// <summary>
8889
/// Field names for validation errors.
8990
/// </summary>
@@ -94,4 +95,4 @@ public static class ValidationFields
9495
/// </summary>
9596
public const string General = "_general";
9697
}
97-
}
98+
}

0 commit comments

Comments
 (0)