public void Parse_should_correctly_parse_not_contains_filter_expression(string expression, string expectedKey)
        {
            var filter = TagFilterExpressionHelpers.Parse(expression);

            filter.Should().BeOfType <NotContainsTagFilter>();
            filter.Should().BeEquivalentTo(new NotContainsTagFilter(expectedKey));
        }
        public void Parse_should_correctly_parse_equals_filter_expression(string expression, string expectedKey, string expectedValue)
        {
            var filter = TagFilterExpressionHelpers.Parse(expression);

            filter.Should().BeOfType <EqualsTagFilter>();
            filter.Should().BeEquivalentTo(new EqualsTagFilter(expectedKey, expectedValue));
        }
Beispiel #3
0
        public void Should_filter_some_replicas_when_they_has_no_tags_and_filter_was_set_in_constructor()
        {
            var applicationInfo = new ApplicationInfo(environment, application, null);

            topology = ServiceTopology.Build(replicas, applicationInfo.Properties.SetPersistentReplicaTags(replica1.ToString(), new TagCollection {
                "tag1"
            }));
            var filter1    = new ServiceDiscoveryReplicasFilter(serviceLocator, environment, application, log, collection => collection.ContainsKey("tag1"));
            var newContext = new FakeContext(new RequestParameters());

            filter1.Filter(replicas, newContext).Should().BeEquivalentTo(replica1);

            var filter2 = new ServiceDiscoveryReplicasFilter(serviceLocator, environment, application, log, new ContainsTagFilter("tag1"));

            filter2.Filter(replicas, newContext).Should().BeEquivalentTo(replica1);

            var filter3 = new ServiceDiscoveryReplicasFilter(serviceLocator, environment, application, log, TagFilterExpressionHelpers.Parse("tag1"));

            filter3.Filter(replicas, newContext).Should().BeEquivalentTo(replica1);
        }