Skip to content

Commit

Permalink
refactor: ExceptionMiddlewareTests.cs initialization
Browse files Browse the repository at this point in the history
Simplified the initialization of HttpContext in the ExceptionMiddlewareTests class. This refactor removes unnecessary lines and makes the code cleaner, moving the initialization of the _context field directly in its declaration.
  • Loading branch information
kamilbaczek committed Nov 23, 2023
1 parent ce1c727 commit 3738b58
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ namespace EvolutionaryArchitecture.Fitnet.Common.Api.UnitTests;

public sealed class ExceptionMiddlewareTests
{
private readonly HttpContext _context;

public ExceptionMiddlewareTests() => _context = GetHttpContext();
private readonly HttpContext _context = GetHttpContext();

[Fact]
internal async Task Given_business_rule_validation_exception_Then_returns_conflict()
Expand Down Expand Up @@ -45,8 +43,8 @@ internal async Task Given_other_than_business_rule_validation_exception_Then_ret
responseMessage.Should().Be(exceptionMessage);
}

private static HttpContext GetHttpContext() =>
new DefaultHttpContext
private static DefaultHttpContext GetHttpContext() =>
new()
{
Response =
{
Expand Down

0 comments on commit 3738b58

Please sign in to comment.