Activate ChangeToken when Ocelot's configuration changes #1037

* Add configuration change token (#1036)

* Add IOptionsMonitor<IInternalConfiguration>

* Activate change token from *ConfigurationRepository instead of FileAndInternalConfigurationSetter; add acceptance & integration tests

* Update documentation

* Use IWebHostEnvironment as IHostingEnvironment deprecated

Co-authored-by: Chris Swinchatt <chrisswinchatt@gmail.com>
This commit is contained in:
Tom Pallister
2020-02-04 20:50:40 +00:00
committed by GitHub
parent 473d50ff36
commit 86e8d66daf
17 changed files with 1546 additions and 1111 deletions

View File

@@ -0,0 +1,35 @@
namespace Ocelot.UnitTests.Configuration.ChangeTracking
{
using Ocelot.Configuration.ChangeTracking;
using Shouldly;
using TestStack.BDDfy;
using Xunit;
public class OcelotConfigurationChangeTokenSourceTests
{
private readonly IOcelotConfigurationChangeTokenSource _source;
public OcelotConfigurationChangeTokenSourceTests()
{
_source = new OcelotConfigurationChangeTokenSource();
}
[Fact]
public void should_activate_change_token()
{
this.Given(_ => GivenIActivateTheChangeTokenSource())
.Then(_ => ThenTheChangeTokenShouldBeActivated())
.BDDfy();
}
private void GivenIActivateTheChangeTokenSource()
{
_source.Activate();
}
private void ThenTheChangeTokenShouldBeActivated()
{
_source.ChangeToken.HasChanged.ShouldBeTrue();
}
}
}