mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-05 00:10:49 +08:00 
			
		
		
		
	Added some logging at last!
This commit is contained in:
		@@ -14,6 +14,7 @@ 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;
 | 
			
		||||
@@ -24,7 +25,7 @@ namespace Ocelot.UnitTests.Cache
 | 
			
		||||
    {
 | 
			
		||||
        private readonly Mock<IOcelotCache<HttpResponseMessage>> _cacheManager;
 | 
			
		||||
        private readonly Mock<IRequestScopedDataRepository> _scopedRepo;
 | 
			
		||||
 | 
			
		||||
        private Mock<IOcelotLoggerFactory> _mockLoggerFactory;
 | 
			
		||||
        private readonly string _url;
 | 
			
		||||
        private readonly TestServer _server;
 | 
			
		||||
        private readonly HttpClient _client;
 | 
			
		||||
@@ -35,11 +36,15 @@ namespace Ocelot.UnitTests.Cache
 | 
			
		||||
        {
 | 
			
		||||
            _cacheManager = new Mock<IOcelotCache<HttpResponseMessage>>();
 | 
			
		||||
            _scopedRepo = new Mock<IRequestScopedDataRepository>();
 | 
			
		||||
 | 
			
		||||
            SetUpLogger();
 | 
			
		||||
 | 
			
		||||
            _url = "http://localhost:51879";
 | 
			
		||||
            var builder = new WebHostBuilder()
 | 
			
		||||
                .ConfigureServices(x =>
 | 
			
		||||
                {
 | 
			
		||||
                    x.AddLogging();
 | 
			
		||||
                    x.AddSingleton(_mockLoggerFactory.Object);
 | 
			
		||||
                    x.AddSingleton(_cacheManager.Object);
 | 
			
		||||
                    x.AddSingleton(_scopedRepo.Object);
 | 
			
		||||
                })
 | 
			
		||||
@@ -80,6 +85,17 @@ namespace Ocelot.UnitTests.Cache
 | 
			
		||||
                .BDDfy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void SetUpLogger()
 | 
			
		||||
        {
 | 
			
		||||
            _mockLoggerFactory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
 | 
			
		||||
            var logger = new Mock<IOcelotLogger>();
 | 
			
		||||
 | 
			
		||||
            _mockLoggerFactory
 | 
			
		||||
                .Setup(x => x.CreateLogger<OutputCacheMiddleware>())
 | 
			
		||||
                .Returns(logger.Object);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void GivenTheDownstreamRouteIs()
 | 
			
		||||
        {
 | 
			
		||||
            var reRoute = new ReRouteBuilder().WithIsCached(true).WithCacheOptions(new CacheOptions(100)).Build();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user