예제 #1
0
        private void SetupConsulNodeSource()
        {
            _consulSourceDisposedCounter = 0;

            _consulNode = new Node("ConsulNode", 123);
            _consulSourceWasUndeployed = false;

            _consulNodeSourceFactory = Substitute.For <INodeSourceFactory>();
            _consulNodeSourceFactory.Type.Returns(Consul);
            _consulNodeSourceFactory.IsServiceDeployed(Arg.Any <DeploymentIdentifier>()).Returns(c => !_consulSourceWasUndeployed);
            _consulNodeSourceFactory.CreateNodeSource(Arg.Any <DeploymentIdentifier>())
            .Returns(_ =>
            {
                _createdNodeSources.Add(typeof(INodeSource));
                return(_consulSourceWasUndeployed ? null : CreateNewConsulSource());
            });
        }
예제 #2
0
        private void SetupSlowNodeSource()
        {
            _waitForSlowSourceCreation = new TaskCompletionSource <bool>();

            _slowNodeSource = Substitute.For <INodeSource>();
            _slowNodeSource.GetNodes().Returns(new Node[0]);

            _slowNodeSourceFactory = Substitute.For <INodeSourceFactory>();
            _slowNodeSourceFactory.Type.Returns(SlowSource);
            _slowNodeSourceFactory.IsServiceDeployed(Arg.Any <DeploymentIdentifier>()).Returns(true);
            _slowNodeSourceFactory.CreateNodeSource(Arg.Any <DeploymentIdentifier>())
            .Returns(async _ =>
            {
                _createdNodeSources.Add(typeof(INodeSource));
                await Task.WhenAny(_waitForSlowSourceCreation.Task, Task.Delay(5000));
                return(_slowNodeSource);
            });
        }