Ocelot/test/Ocelot.UnitTests/Rafty/OcelotFiniteStateMachineTests.cs
Tom Pallister 11a2d13f18
Feat/monorepo (#734)
* copied everything from repos back to ocelot repo

* added src projects to sln

* removed all test projects that have no tests

* added all test projects to sln

* removed test not on master

* merged unit tests

* merged acceptance tests

* merged integration tests

* fixed namepaces

* build script creates packages for all projects

* updated docs to make sure no references to external repos that we will remove

* +semver: breaking
2019-01-07 19:52:53 +00:00

46 lines
1.3 KiB
C#

namespace Ocelot.UnitTests.Rafty
{
using Moq;
using Ocelot.Configuration.Setter;
using Provider.Rafty;
using TestStack.BDDfy;
using Xunit;
public class OcelotFiniteStateMachineTests
{
private UpdateFileConfiguration _command;
private readonly OcelotFiniteStateMachine _fsm;
private readonly 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 global::Rafty.Log.LogEntry(_command, _command.GetType(), 0)).Wait();
}
private void ThenTheStateIsUpdated()
{
_setter.Verify(x => x.Set(_command.Configuration), Times.Once);
}
}
}