Example #1
0
        public void ShouldNotCollectIfNoValueIsGiven()
        {
            var collector = new QueryIdCollector();

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

            collector.Collected.Should().Be(-1);
        }
Example #2
0
        public void ShouldNotCollectIfMetadataIsNull()
        {
            var collector = new QueryIdCollector();

            collector.Collect(null);

            collector.Collected.Should().Be(-1);
        }
Example #3
0
        public void ShouldReturnSameCollected()
        {
            var metadata = new Dictionary <string, object> {
                { Key, 5L }
            };
            var collector = new QueryIdCollector();

            collector.Collect(metadata);

            ((IMetadataCollector)collector).Collected.Should().Be(collector.Collected);
        }
Example #4
0
        public void ShouldCollect()
        {
            var metadata = new Dictionary <string, object> {
                { Key, 5L }
            };
            var collector = new QueryIdCollector();

            collector.Collect(metadata);

            collector.Collected.Should().Be(5L);
        }
Example #5
0
        public void ShouldThrowIfValueIsOfWrongType()
        {
            var metadata = new Dictionary <string, object> {
                { Key, false }
            };
            var collector = new QueryIdCollector();

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

            ex.Should().BeOfType <ProtocolException>().Which
            .Message.Should().Contain($"Expected '{Key}' metadata to be of type 'Int64', but got 'Boolean'.");
        }