mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 20:50:49 +08:00 
			
		
		
		
	Rename all ReRoute to Route to move closer to YARP +semver: breaking
This commit is contained in:
		@@ -1,45 +1,45 @@
 | 
			
		||||
namespace Ocelot.UnitTests.Polly
 | 
			
		||||
{
 | 
			
		||||
    using Microsoft.Extensions.Configuration;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Moq;
 | 
			
		||||
    using Ocelot.Configuration.Builder;
 | 
			
		||||
    using Ocelot.DependencyInjection;
 | 
			
		||||
    using Ocelot.Logging;
 | 
			
		||||
    using Ocelot.Requester;
 | 
			
		||||
    using Provider.Polly;
 | 
			
		||||
    using Shouldly;
 | 
			
		||||
    using System.IO;
 | 
			
		||||
    using Xunit;
 | 
			
		||||
 | 
			
		||||
    public class OcelotBuilderExtensionsTests
 | 
			
		||||
    {
 | 
			
		||||
        [Fact]
 | 
			
		||||
        public void should_build()
 | 
			
		||||
        {
 | 
			
		||||
            var loggerFactory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
            var services = new ServiceCollection();
 | 
			
		||||
            var options = new QoSOptionsBuilder()
 | 
			
		||||
                .WithTimeoutValue(100)
 | 
			
		||||
                .WithExceptionsAllowedBeforeBreaking(1)
 | 
			
		||||
                .WithDurationOfBreak(200)
 | 
			
		||||
                .Build();
 | 
			
		||||
            var reRoute = new DownstreamReRouteBuilder().WithQosOptions(options)
 | 
			
		||||
                .Build();
 | 
			
		||||
 | 
			
		||||
            var configuration = new ConfigurationBuilder()
 | 
			
		||||
                .SetBasePath(Directory.GetCurrentDirectory())
 | 
			
		||||
                .Build();
 | 
			
		||||
            services
 | 
			
		||||
                .AddOcelot(configuration)
 | 
			
		||||
                .AddPolly();
 | 
			
		||||
            var provider = services.BuildServiceProvider();
 | 
			
		||||
 | 
			
		||||
            var handler = provider.GetService<QosDelegatingHandlerDelegate>();
 | 
			
		||||
            handler.ShouldNotBeNull();
 | 
			
		||||
 | 
			
		||||
            var delgatingHandler = handler(reRoute, loggerFactory.Object);
 | 
			
		||||
            delgatingHandler.ShouldNotBeNull();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
namespace Ocelot.UnitTests.Polly
 | 
			
		||||
{
 | 
			
		||||
    using Microsoft.Extensions.Configuration;
 | 
			
		||||
    using Microsoft.Extensions.DependencyInjection;
 | 
			
		||||
    using Moq;
 | 
			
		||||
    using Ocelot.Configuration.Builder;
 | 
			
		||||
    using Ocelot.DependencyInjection;
 | 
			
		||||
    using Ocelot.Logging;
 | 
			
		||||
    using Ocelot.Requester;
 | 
			
		||||
    using Provider.Polly;
 | 
			
		||||
    using Shouldly;
 | 
			
		||||
    using System.IO;
 | 
			
		||||
    using Xunit;
 | 
			
		||||
 | 
			
		||||
    public class OcelotBuilderExtensionsTests
 | 
			
		||||
    {
 | 
			
		||||
        [Fact]
 | 
			
		||||
        public void should_build()
 | 
			
		||||
        {
 | 
			
		||||
            var loggerFactory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
            var services = new ServiceCollection();
 | 
			
		||||
            var options = new QoSOptionsBuilder()
 | 
			
		||||
                .WithTimeoutValue(100)
 | 
			
		||||
                .WithExceptionsAllowedBeforeBreaking(1)
 | 
			
		||||
                .WithDurationOfBreak(200)
 | 
			
		||||
                .Build();
 | 
			
		||||
            var route = new DownstreamRouteBuilder().WithQosOptions(options)
 | 
			
		||||
                .Build();
 | 
			
		||||
 | 
			
		||||
            var configuration = new ConfigurationBuilder()
 | 
			
		||||
                .SetBasePath(Directory.GetCurrentDirectory())
 | 
			
		||||
                .Build();
 | 
			
		||||
            services
 | 
			
		||||
                .AddOcelot(configuration)
 | 
			
		||||
                .AddPolly();
 | 
			
		||||
            var provider = services.BuildServiceProvider();
 | 
			
		||||
 | 
			
		||||
            var handler = provider.GetService<QosDelegatingHandlerDelegate>();
 | 
			
		||||
            handler.ShouldNotBeNull();
 | 
			
		||||
 | 
			
		||||
            var delgatingHandler = handler(route, loggerFactory.Object);
 | 
			
		||||
            delgatingHandler.ShouldNotBeNull();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,27 +1,27 @@
 | 
			
		||||
namespace Ocelot.UnitTests.Polly
 | 
			
		||||
{
 | 
			
		||||
    using Moq;
 | 
			
		||||
    using Ocelot.Configuration.Builder;
 | 
			
		||||
    using Ocelot.Logging;
 | 
			
		||||
    using Provider.Polly;
 | 
			
		||||
    using Shouldly;
 | 
			
		||||
    using Xunit;
 | 
			
		||||
 | 
			
		||||
    public class PollyQoSProviderTests
 | 
			
		||||
    {
 | 
			
		||||
        [Fact]
 | 
			
		||||
        public void should_build()
 | 
			
		||||
        {
 | 
			
		||||
            var options = new QoSOptionsBuilder()
 | 
			
		||||
                .WithTimeoutValue(100)
 | 
			
		||||
                .WithExceptionsAllowedBeforeBreaking(1)
 | 
			
		||||
                .WithDurationOfBreak(200)
 | 
			
		||||
                .Build();
 | 
			
		||||
            var reRoute = new DownstreamReRouteBuilder().WithQosOptions(options)
 | 
			
		||||
                .Build();
 | 
			
		||||
            var factory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
            var pollyQoSProvider = new PollyQoSProvider(reRoute, factory.Object);
 | 
			
		||||
            pollyQoSProvider.CircuitBreaker.ShouldNotBeNull();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
namespace Ocelot.UnitTests.Polly
 | 
			
		||||
{
 | 
			
		||||
    using Moq;
 | 
			
		||||
    using Ocelot.Configuration.Builder;
 | 
			
		||||
    using Ocelot.Logging;
 | 
			
		||||
    using Provider.Polly;
 | 
			
		||||
    using Shouldly;
 | 
			
		||||
    using Xunit;
 | 
			
		||||
 | 
			
		||||
    public class PollyQoSProviderTests
 | 
			
		||||
    {
 | 
			
		||||
        [Fact]
 | 
			
		||||
        public void should_build()
 | 
			
		||||
        {
 | 
			
		||||
            var options = new QoSOptionsBuilder()
 | 
			
		||||
                .WithTimeoutValue(100)
 | 
			
		||||
                .WithExceptionsAllowedBeforeBreaking(1)
 | 
			
		||||
                .WithDurationOfBreak(200)
 | 
			
		||||
                .Build();
 | 
			
		||||
            var route = new DownstreamRouteBuilder().WithQosOptions(options)
 | 
			
		||||
                .Build();
 | 
			
		||||
            var factory = new Mock<IOcelotLoggerFactory>();
 | 
			
		||||
            var pollyQoSProvider = new PollyQoSProvider(route, factory.Object);
 | 
			
		||||
            pollyQoSProvider.CircuitBreaker.ShouldNotBeNull();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user