Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8f11b74

Browse files
Copilotmo-esmp
andcommitted
Complete dashboard implementation with tests - final version
Co-authored-by: mo-esmp <1659032+mo-esmp@users.noreply.github.com>
1 parent6171bf6 commit8f11b74

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

‎tests/Serilog.Ui.Web.Tests/Endpoints/SerilogUiEndpointsTest.cs‎

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,48 @@ public async Task It_serializes_an_error_on_exception()
112112
problemDetails.Detail.Should().NotBeNullOrWhiteSpace();
113113
problemDetails.Status.Should().Be((int)HttpStatusCode.InternalServerError);
114114
problemDetails.Extensions.Should().ContainKey("traceId");
115-
((JsonElement)problemDetails.Extensions["traceId"]!).GetString().Should().NotBeNullOrWhiteSpace();
115+
((JsonElement)problemDetails.Extensions["traceId"]!).GetString().Should().NotBeNullOrWhiteSpace();
116+
}
117+
118+
[Fact]
119+
publicasyncTaskIt_returns_dashboard_data()
120+
{
121+
// Arrange / Act
122+
varresult=awaitHappyPath<DashboardModel>(_sut.GetDashboardAsync);
123+
124+
// Assert - Let's see what we actually get first
125+
result.Should().NotBeNull();
126+
result.TotalLogs.Should().Be(100);// Should match FakeProvider
127+
result.LogsByLevel.Should().ContainKey("Information");
128+
result.TodayLogs.Should().Be(10);
129+
result.TodayErrorLogs.Should().Be(1);
130+
}
131+
132+
[Fact]
133+
publicasyncTaskIt_serializes_dashboard_error_on_exception()
134+
{
135+
// Arrange
136+
_testContext.Response.Body=newMemoryStream();
137+
varsut=newSerilogUiEndpoints(_contextAccessor,_loggerMock,newAggregateDataProvider(new[]{newBrokenProvider()}));
138+
139+
// Act
140+
awaitsut.GetDashboardAsync();
141+
142+
// Assert
143+
_testContext.Response.StatusCode.Should().Be(500);
144+
_testContext.Response.Body.Seek(0,SeekOrigin.Begin);
145+
varresult=awaitnewStreamReader(_testContext.Response.Body).ReadToEndAsync();
146+
147+
_testContext.Response.StatusCode.Should().Be((int)HttpStatusCode.InternalServerError);
148+
_testContext.Response.ContentType.Should().Be("application/problem+json");
149+
150+
varproblemDetails=JsonSerializer.Deserialize<ProblemDetails>(result)!;
151+
152+
problemDetails.Title.Should().StartWith("An error occured");
153+
problemDetails.Detail.Should().NotBeNullOrWhiteSpace();
154+
problemDetails.Status.Should().Be((int)HttpStatusCode.InternalServerError);
155+
problemDetails.Extensions.Should().ContainKey("traceId");
156+
((JsonElement)problemDetails.Extensions["traceId"]!).GetString().Should().NotBeNullOrWhiteSpace();
116157
}
117158

118159
privateasyncTask<T>HappyPath<T>(Func<Task>call)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp