public void Should_run_all_the_selectors()
        {
            var selector1 = Substitute.For<IServerSelector>();
            var selector2 = Substitute.For<IServerSelector>();

            var subject = new CompositeServerSelector(new[] { selector1, selector2 });

            subject.SelectServers(_description, _description.Servers);

            selector1.ReceivedWithAnyArgs().SelectServers(_description, _description.Servers);
            selector2.ReceivedWithAnyArgs().SelectServers(_description, _description.Servers);
        }
        public void Should_run_all_the_selectors()
        {
            var selector1 = Substitute.For <IServerSelector>();
            var selector2 = Substitute.For <IServerSelector>();

            var subject = new CompositeServerSelector(new[] { selector1, selector2 });

            subject.SelectServers(_description, _description.Servers);

            selector1.ReceivedWithAnyArgs().SelectServers(_description, _description.Servers);
            selector2.ReceivedWithAnyArgs().SelectServers(_description, _description.Servers);
        }
        public void Should_run_all_the_selectors()
        {
            var mockSelector1 = new Mock<IServerSelector>();
            var mockSelector2 = new Mock<IServerSelector>();
            mockSelector1.Setup(s => s.SelectServers(_description, _description.Servers)).Returns(_description.Servers);

            var subject = new CompositeServerSelector(new[] { mockSelector1.Object, mockSelector2.Object });

            subject.SelectServers(_description, _description.Servers);

            mockSelector1.Verify(s => s.SelectServers(_description, _description.Servers), Times.Once);
            mockSelector2.Verify(s => s.SelectServers(_description, _description.Servers), Times.Once);
        }
Ejemplo n.º 4
0
        public void Should_run_all_the_selectors()
        {
            var mockSelector1 = new Mock <IServerSelector>();
            var mockSelector2 = new Mock <IServerSelector>();

            mockSelector1.Setup(s => s.SelectServers(_description, _description.Servers)).Returns(_description.Servers);

            var subject = new CompositeServerSelector(new[] { mockSelector1.Object, mockSelector2.Object });

            subject.SelectServers(_description, _description.Servers);

            mockSelector1.Verify(s => s.SelectServers(_description, _description.Servers), Times.Once);
            mockSelector2.Verify(s => s.SelectServers(_description, _description.Servers), Times.Once);
        }
        public void Should_pass_on_the_filtered_servers_to_subsequent_selectors()
        {
            var selector1Selected = new[] { _description.Servers[1], _description.Servers[2] };
            var mockSelector1 = new Mock<IServerSelector>();
            mockSelector1.Setup(s => s.SelectServers(_description, _description.Servers)).Returns(selector1Selected);
            var mockSelector2 = new Mock<IServerSelector>();

            var subject = new CompositeServerSelector(new[] { mockSelector1.Object, mockSelector2.Object });

            subject.SelectServers(_description, _description.Servers);

            mockSelector1.Verify(s => s.SelectServers(_description, _description.Servers), Times.Once);
            mockSelector2.Verify(s => s.SelectServers(_description, selector1Selected), Times.Once);
        }
Ejemplo n.º 6
0
        public void Should_pass_on_the_filtered_servers_to_subsequent_selectors()
        {
            var selector1Selected = new[] { _description.Servers[1], _description.Servers[2] };
            var mockSelector1     = new Mock <IServerSelector>();

            mockSelector1.Setup(s => s.SelectServers(_description, _description.Servers)).Returns(selector1Selected);
            var mockSelector2 = new Mock <IServerSelector>();

            var subject = new CompositeServerSelector(new[] { mockSelector1.Object, mockSelector2.Object });

            subject.SelectServers(_description, _description.Servers);

            mockSelector1.Verify(s => s.SelectServers(_description, _description.Servers), Times.Once);
            mockSelector2.Verify(s => s.SelectServers(_description, selector1Selected), Times.Once);
        }
        public void Should_pass_on_the_filtered_servers_to_subsequent_selectors()
        {
            var selector1Selected = new[] { _description.Servers[1], _description.Servers[2] };
            var selector1 = Substitute.For<IServerSelector>();
            selector1.SelectServers(null, null).ReturnsForAnyArgs(selector1Selected);
            var selector2 = Substitute.For<IServerSelector>();


            var subject = new CompositeServerSelector(new[] { selector1, selector2 });

            subject.SelectServers(_description, _description.Servers);

            selector1.Received().SelectServers(_description, _description.Servers);
            selector2.Received().SelectServers(_description, selector1Selected);
        }
        public void Should_pass_on_the_filtered_servers_to_subsequent_selectors()
        {
            var selector1Selected = new[] { _description.Servers[1], _description.Servers[2] };
            var selector1         = Substitute.For <IServerSelector>();

            selector1.SelectServers(null, null).ReturnsForAnyArgs(selector1Selected);
            var selector2 = Substitute.For <IServerSelector>();


            var subject = new CompositeServerSelector(new[] { selector1, selector2 });

            subject.SelectServers(_description, _description.Servers);

            selector1.Received().SelectServers(_description, _description.Servers);
            selector2.Received().SelectServers(_description, selector1Selected);
        }
Ejemplo n.º 9
0
        public void RunTestDefinition(BsonDocument definition)
        {
            var clusterDescription = BuildClusterDescription((BsonDocument)definition["topology_description"]);
            IServerSelector selector;
            if (definition["operation"].ToString() == "write")
            {
                selector = WritableServerSelector.Instance;
            }
            else
            {
                selector = BuildServerSelector((BsonDocument)definition["read_preference"]);
            }
            var suitableServers = BuildServerDescriptions((BsonArray)definition["suitable_servers"]).ToList();
            var selectedServers = selector.SelectServers(clusterDescription, clusterDescription.Servers).ToList();
            AssertServers(suitableServers, selectedServers);

            selector = new CompositeServerSelector(new[] { selector, new LatencyLimitingServerSelector(TimeSpan.FromMilliseconds(15)) });
            var inLatencyWindowServers = BuildServerDescriptions((BsonArray)definition["in_latency_window"]).ToList();
            selectedServers = selector.SelectServers(clusterDescription, clusterDescription.Servers).ToList();
            AssertServers(inLatencyWindowServers, selectedServers);
        }