Пример #1
0
        public IConfigurationProvider Build(IConfigurationBuilder builder)
        {
            var consulClientFactory = new ConsulClientFactory(this);
            var consulConfigClient  = new ConsulConfigurationClient(consulClientFactory);

            return(new ConsulConfigurationProvider(this, consulConfigClient));
        }
        private ConsulConfigurationClientTests()
        {
            _kvMock = new Mock <IKVEndpoint>(MockBehavior.Strict);

            var consulClientMock = new Mock <IConsulClient>(MockBehavior.Strict);

            consulClientMock.Setup(cc => cc.Dispose());
            consulClientMock.Setup(cc => cc.KV).Returns(_kvMock.Object);
            var consulClientFactoryMock = new Mock <IConsulClientFactory>(MockBehavior.Strict);

            consulClientFactoryMock.Setup(ccf => ccf.Create()).Returns(consulClientMock.Object);

            _consulConfigurationClient = new ConsulConfigurationClient(consulClientFactoryMock.Object);
        }
Пример #3
0
        public void SetUp()
        {
            _cancellationTokenSource = new CancellationTokenSource();
            _cancellationToken       = _cancellationTokenSource.Token;

            _consulConfigurationSourceMock = new Mock <IConsulConfigurationSource>(MockBehavior.Strict);
            _consulConfigurationSourceMock.SetupGet(ccs => ccs.CancellationToken).Returns(_cancellationToken);
            _consulConfigurationSourceMock.SetupGet(ccs => ccs.Key).Returns(_Key);

            _kvMock = new Mock <IKVEndpoint>(MockBehavior.Strict);

            _consulClientMock = new Mock <IConsulClient>(MockBehavior.Strict);
            _consulClientMock.Setup(cc => cc.Dispose());
            _consulClientMock.SetupGet(cc => cc.KV).Returns(_kvMock.Object);
            _consulClientFactoryMock = new Mock <IConsulClientFactory>(MockBehavior.Strict);
            _consulClientFactoryMock.Setup(ccf => ccf.Create()).Returns(_consulClientMock.Object);

            _consulConfigurationClient = new ConsulConfigurationClient(_consulClientFactoryMock.Object, _consulConfigurationSourceMock.Object);
        }
        private ConsulConfigurationClientTests()
        {
            _cancellationTokenSource = new CancellationTokenSource();
            _cancellationToken       = _cancellationTokenSource.Token;

            var consulConfigurationSourceMock = new Mock <IConsulConfigurationSource>(MockBehavior.Strict);

            consulConfigurationSourceMock.Setup(ccs => ccs.CancellationToken).Returns(_cancellationToken);
            consulConfigurationSourceMock.Setup(ccs => ccs.Key).Returns("Test");

            _kvMock = new Mock <IKVEndpoint>(MockBehavior.Strict);

            var consulClientMock = new Mock <IConsulClient>(MockBehavior.Strict);

            consulClientMock.Setup(cc => cc.Dispose());
            consulClientMock.Setup(cc => cc.KV).Returns(_kvMock.Object);
            var consulClientFactoryMock = new Mock <IConsulClientFactory>(MockBehavior.Strict);

            consulClientFactoryMock.Setup(ccf => ccf.Create()).Returns(consulClientMock.Object);

            _consulConfigurationClient = new ConsulConfigurationClient(
                consulClientFactoryMock.Object,
                consulConfigurationSourceMock.Object);
        }