Skip to content

Commit

Permalink
Exception mapper naming (#1211)
Browse files Browse the repository at this point in the history
* Fix typo in class and file name
"Exeption" -> "Exception"

* And rename the test

* IDE1006 Naming rule violation: These words must begin with upper case characters: {should_*}
Fix name violation

---------

Co-authored-by: Anthony Steele <[email protected]>
Co-authored-by: raman-m <[email protected]>
  • Loading branch information
3 people authored Sep 22, 2023
1 parent 818d1fc commit 455d7d3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/Ocelot/DependencyInjection/OcelotBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public OcelotBuilder(IServiceCollection services, IConfiguration configurationRo
Services.TryAddSingleton<IDownstreamRequestCreator, DownstreamRequestCreator>();
Services.TryAddSingleton<IFrameworkDescription, FrameworkDescription>();
Services.TryAddSingleton<IQoSFactory, QoSFactory>();
Services.TryAddSingleton<IExceptionToErrorMapper, HttpExeptionToErrorMapper>();
Services.TryAddSingleton<IExceptionToErrorMapper, HttpExceptionToErrorMapper>();
Services.TryAddSingleton<IVersionCreator, HttpVersionCreator>();

//add security
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

namespace Ocelot.Requester
{
public class HttpExeptionToErrorMapper : IExceptionToErrorMapper
public class HttpExceptionToErrorMapper : IExceptionToErrorMapper
{
private readonly Dictionary<Type, Func<Exception, Error>> _mappers;

public HttpExeptionToErrorMapper(IServiceProvider serviceProvider)
public HttpExceptionToErrorMapper(IServiceProvider serviceProvider)
{
_mappers = serviceProvider.GetService<Dictionary<Type, Func<Exception, Error>>>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,52 @@

namespace Ocelot.UnitTests.Requester
{
public class HttpExeptionToErrorMapperTests
public class HttpExceptionToErrorMapperTests
{
private HttpExeptionToErrorMapper _mapper;
private HttpExceptionToErrorMapper _mapper;
private readonly ServiceCollection _services;

public HttpExeptionToErrorMapperTests()
public HttpExceptionToErrorMapperTests()
{
_services = new ServiceCollection();
var provider = _services.BuildServiceProvider();
_mapper = new HttpExeptionToErrorMapper(provider);
_mapper = new HttpExceptionToErrorMapper(provider);
}

[Fact]
public void should_return_default_error_because_mappers_are_null()
public void Should_return_default_error_because_mappers_are_null()
{
var error = _mapper.Map(new Exception());

error.ShouldBeOfType<UnableToCompleteRequestError>();
}

[Fact]
public void should_return_request_canceled()
public void Should_return_request_canceled()
{
var error = _mapper.Map(new OperationCanceledException());

error.ShouldBeOfType<RequestCanceledError>();
}

[Fact]
public void should_return_ConnectionToDownstreamServiceError()
public void Should_return_ConnectionToDownstreamServiceError()
{
var error = _mapper.Map(new HttpRequestException());

error.ShouldBeOfType<ConnectionToDownstreamServiceError>();
}

[Fact]
public void should_return_request_canceled_for_subtype()
public void Should_return_request_canceled_for_subtype()
{
var error = _mapper.Map(new SomeException());

error.ShouldBeOfType<RequestCanceledError>();
}

[Fact]
public void should_return_error_from_mapper()
public void Should_return_error_from_mapper()
{
var errorMapping = new Dictionary<Type, Func<Exception, Error>>
{
Expand All @@ -72,7 +72,7 @@ public void should_return_error_from_mapper()

var provider = _services.BuildServiceProvider();

_mapper = new HttpExeptionToErrorMapper(provider);
_mapper = new HttpExceptionToErrorMapper(provider);

var error = _mapper.Map(new TaskCanceledException());

Expand Down

0 comments on commit 455d7d3

Please sign in to comment.