Example #1
0
        public void ShouldCollectWithoutChildPlans()
        {
            var metadata = new Dictionary <string, object>
            {
                {
                    Key, new Dictionary <string, object>
                    {
                        { "operatorType", "opType" },
                        { "args", new Dictionary <string, object> {
                              { "a", 1L }
                          } },
                        {
                            "identifiers", new List <object>
                            {
                                "a", "b", "c"
                            }
                        }
                    }
                }
            };
            var collector = new PlanCollector();

            collector.Collect(metadata);

            collector.Collected.Should().BeEquivalentTo(new Plan("opType", new Dictionary <string, object> {
                { "a", 1L }
            },
                                                                 new List <string> {
                "a", "b", "c"
            }, new List <IPlan>()));
        }
Example #2
0
        public void ShouldNotCollectIfNoValueIsGiven()
        {
            var collector = new PlanCollector();

            collector.Collect(new Dictionary <string, object>());

            collector.Collected.Should().BeNull();
        }
Example #3
0
        public void ShouldNotCollectIfMetadataIsNull()
        {
            var collector = new PlanCollector();

            collector.Collect(null);

            collector.Collected.Should().BeNull();
        }
Example #4
0
        public void ShouldNotCollectIfValueIsEmpty()
        {
            var collector = new PlanCollector();

            collector.Collect(new Dictionary <string, object> {
                { Key, new Dictionary <string, object>() }
            });

            collector.Collected.Should().BeNull();
        }
Example #5
0
        public void ShouldThrowIfValueIsOfWrongType()
        {
            var metadata = new Dictionary <string, object> {
                { Key, true }
            };
            var collector = new PlanCollector();

            var ex = Record.Exception(() => collector.Collect(metadata));

            ex.Should().BeOfType <ProtocolException>().Which
            .Message.Should()
            .Contain($"Expected '{Key}' metadata to be of type 'IDictionary<String,Object>', but got 'Boolean'.");
        }
Example #6
0
        public void ShouldReturnSameCollected()
        {
            var metadata = new Dictionary <string, object>
            {
                {
                    Key, new Dictionary <string, object>
                    {
                        { "operatorType", "opType" }
                    }
                }
            };
            var collector = new PlanCollector();

            collector.Collect(metadata);

            ((IMetadataCollector)collector).Collected.Should().BeSameAs(collector.Collected);
        }
Example #7
0
        public void ShouldCollectWithDefaultValues()
        {
            var metadata = new Dictionary <string, object>
            {
                {
                    Key, new Dictionary <string, object>
                    {
                        { "operatorType", "opType" }
                    }
                }
            };
            var collector = new PlanCollector();

            collector.Collect(metadata);

            collector.Collected.Should().BeEquivalentTo(new Plan("opType", new Dictionary <string, object>(),
                                                                 new List <string>(), new List <IPlan>()));
        }
Example #8
0
        public void ShouldThrowIfOperatorTypeIsMissing()
        {
            var metadata = new Dictionary <string, object>
            {
                {
                    Key, new Dictionary <string, object>
                    {
                        { "args", new Dictionary <string, object>() }
                    }
                }
            };
            var collector = new PlanCollector();

            var ex = Record.Exception(() => collector.Collect(metadata));

            ex.Should().BeOfType <ProtocolException>().Which
            .Message.Should()
            .Be("Expected key 'operatorType' to be present in the dictionary, but could not find.");
        }