mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 06:48:16 +08:00
Added some logging at last!
This commit is contained in:
@ -8,10 +8,12 @@ using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Moq;
|
||||
using Ocelot.Authorisation;
|
||||
using Ocelot.Cache.Middleware;
|
||||
using Ocelot.Configuration.Builder;
|
||||
using Ocelot.DownstreamRouteFinder;
|
||||
using Ocelot.DownstreamRouteFinder.UrlMatcher;
|
||||
using Ocelot.Infrastructure.RequestData;
|
||||
using Ocelot.Logging;
|
||||
using Ocelot.Responses;
|
||||
using TestStack.BDDfy;
|
||||
using Xunit;
|
||||
@ -29,15 +31,19 @@ namespace Ocelot.UnitTests.Authorization
|
||||
private readonly HttpClient _client;
|
||||
private HttpResponseMessage _result;
|
||||
private OkResponse<DownstreamRoute> _downstreamRoute;
|
||||
private Mock<IOcelotLoggerFactory> _mockLoggerFactory;
|
||||
|
||||
public AuthorisationMiddlewareTests()
|
||||
{
|
||||
_url = "http://localhost:51879";
|
||||
_scopedRepository = new Mock<IRequestScopedDataRepository>();
|
||||
_authService = new Mock<IAuthoriser>();
|
||||
SetUpLogger();
|
||||
|
||||
var builder = new WebHostBuilder()
|
||||
.ConfigureServices(x =>
|
||||
{
|
||||
x.AddSingleton(_mockLoggerFactory.Object);
|
||||
x.AddSingleton(_authService.Object);
|
||||
x.AddSingleton(_scopedRepository.Object);
|
||||
})
|
||||
@ -65,6 +71,17 @@ namespace Ocelot.UnitTests.Authorization
|
||||
.BDDfy();
|
||||
}
|
||||
|
||||
private void SetUpLogger()
|
||||
{
|
||||
_mockLoggerFactory = new Mock<IOcelotLoggerFactory>();
|
||||
|
||||
var logger = new Mock<IOcelotLogger>();
|
||||
|
||||
_mockLoggerFactory
|
||||
.Setup(x => x.CreateLogger<AuthorisationMiddleware>())
|
||||
.Returns(logger.Object);
|
||||
}
|
||||
|
||||
private void GivenTheAuthServiceReturns(Response<bool> expected)
|
||||
{
|
||||
_authService
|
||||
|
Reference in New Issue
Block a user