public void ShouldNotOverwriteNonOptionalConfigIfDoesNotExistOnReload() { const string key = "Key"; const string value = "Test"; var originalData = new Dictionary <string, string> { { key, value } }; Action <object> onChangeAction = null; _consulConfigSourceMock.SetupGet(ccs => ccs.Optional).Returns(false); _consulConfigSourceMock.SetupGet(ccs => ccs.ReloadOnChange).Returns(true); _configQueryResultMock.SetupGet(cqr => cqr.Exists).Returns(false); _changeTokenMock .Setup(ct => ct.RegisterChangeCallback(It.IsAny <Action <object> >(), It.IsAny <object>())) .Callback((Action <object> action, object state) => { onChangeAction = action; }) .Returns(null as IDisposable); var configProvider = new ConsulConfigurationProvider(_consulConfigSourceMock.Object, _consulConfigClientMock.Object); DoLoad(originalData); onChangeAction(null); string actualValue; Assert.That(configProvider.TryGet(key, out actualValue), Is.True); }
public void ShouldParseLoadedConfigIntoDictionary(string actualKey, string lookupKey) { const string configValue = "Value"; var parsedData = new Dictionary <string, string> { { actualKey, configValue } }; DoLoad(parsedData); _consulConfigProvider.TryGet(lookupKey, out string actualValue); Assert.That(actualValue, Is.EqualTo(configValue)); }