mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 20:50:49 +08:00 
			
		
		
		
	hacked together load balancing reroutes in fileconfig (#211)
* hacked together load balancing reroutes in fileconfig * some renaming and refactoring * more renames * hacked away the old config json * test for issue 213 * renamed key * dont share ports * oops * updated docs * mvoed docs around * port being used
This commit is contained in:
		@@ -1,45 +1,45 @@
 | 
			
		||||
using Moq;
 | 
			
		||||
using Ocelot.Configuration.Setter;
 | 
			
		||||
using Ocelot.Raft;
 | 
			
		||||
using TestStack.BDDfy;
 | 
			
		||||
using Xunit;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.UnitTests.Raft
 | 
			
		||||
{
 | 
			
		||||
    public class OcelotFiniteStateMachineTests
 | 
			
		||||
    {
 | 
			
		||||
        private UpdateFileConfiguration _command;
 | 
			
		||||
        private OcelotFiniteStateMachine _fsm;
 | 
			
		||||
        private Mock<IFileConfigurationSetter> _setter;
 | 
			
		||||
 | 
			
		||||
        public OcelotFiniteStateMachineTests()
 | 
			
		||||
        {
 | 
			
		||||
            _setter = new Mock<IFileConfigurationSetter>();
 | 
			
		||||
            _fsm = new OcelotFiniteStateMachine(_setter.Object);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Fact]
 | 
			
		||||
        public void should_handle_update_file_configuration_command()
 | 
			
		||||
        {
 | 
			
		||||
            this.Given(x => GivenACommand(new UpdateFileConfiguration(new Ocelot.Configuration.File.FileConfiguration())))
 | 
			
		||||
                .When(x => WhenTheCommandIsHandled())
 | 
			
		||||
                .Then(x => ThenTheStateIsUpdated())
 | 
			
		||||
                .BDDfy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void GivenACommand(UpdateFileConfiguration command)
 | 
			
		||||
        {
 | 
			
		||||
            _command = command;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void WhenTheCommandIsHandled()
 | 
			
		||||
        {
 | 
			
		||||
             _fsm.Handle(new Rafty.Log.LogEntry(_command, _command.GetType(), 0));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void ThenTheStateIsUpdated()
 | 
			
		||||
        {
 | 
			
		||||
            _setter.Verify(x => x.Set(_command.Configuration), Times.Once);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
using Moq;
 | 
			
		||||
using Ocelot.Configuration.Setter;
 | 
			
		||||
using Ocelot.Raft;
 | 
			
		||||
using TestStack.BDDfy;
 | 
			
		||||
using Xunit;
 | 
			
		||||
 | 
			
		||||
namespace Ocelot.UnitTests.Raft
 | 
			
		||||
{
 | 
			
		||||
    public class OcelotFiniteStateMachineTests
 | 
			
		||||
    {
 | 
			
		||||
        private UpdateFileConfiguration _command;
 | 
			
		||||
        private OcelotFiniteStateMachine _fsm;
 | 
			
		||||
        private Mock<IFileConfigurationSetter> _setter;
 | 
			
		||||
 | 
			
		||||
        public OcelotFiniteStateMachineTests()
 | 
			
		||||
        {
 | 
			
		||||
            _setter = new Mock<IFileConfigurationSetter>();
 | 
			
		||||
            _fsm = new OcelotFiniteStateMachine(_setter.Object);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Fact]
 | 
			
		||||
        public void should_handle_update_file_configuration_command()
 | 
			
		||||
        {
 | 
			
		||||
            this.Given(x => GivenACommand(new UpdateFileConfiguration(new Ocelot.Configuration.File.FileConfiguration())))
 | 
			
		||||
                .When(x => WhenTheCommandIsHandled())
 | 
			
		||||
                .Then(x => ThenTheStateIsUpdated())
 | 
			
		||||
                .BDDfy();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void GivenACommand(UpdateFileConfiguration command)
 | 
			
		||||
        {
 | 
			
		||||
            _command = command;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void WhenTheCommandIsHandled()
 | 
			
		||||
        {
 | 
			
		||||
             _fsm.Handle(new Rafty.Log.LogEntry(_command, _command.GetType(), 0));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void ThenTheStateIsUpdated()
 | 
			
		||||
        {
 | 
			
		||||
            _setter.Verify(x => x.Set(_command.Configuration), Times.Once);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user