public void ShouldReturnSameCollected()
        {
            var metadata = new Dictionary <string, object>
            {
                {
                    Key, new Dictionary <string, object>
                    {
                        { "nodes-created", 1L },
                        { "nodes-deleted", 2L },
                        { "relationships-created", 3L },
                        { "relationships-deleted", 4L },
                        { "properties-set", 5L },
                        { "labels-added", 6L },
                        { "labels-removed", 7L },
                        { "indexes-added", 8L },
                        { "indexes-removed", 9L },
                        { "constraints-added", 10L },
                        { "constraints-removed", 11L },
                        { "system-updates", 12L },
                    }
                }
            };
            var collector = new CountersCollector();

            collector.Collect(metadata);

            ((IMetadataCollector)collector).Collected.Should().BeSameAs(collector.Collected);
        }
        public void ShouldCollectMissingCountersAsZero()
        {
            var metadata = new Dictionary <string, object>
            {
                {
                    Key, new Dictionary <string, object>
                    {
                        { "nodes-created", 1L },
                        { "relationships-created", 2L },
                        { "properties-set", 3L },
                        { "labels-added", 4L },
                        { "indexes-added", 5L },
                        { "constraints-added", 6L },
                    }
                }
            };
            var collector = new CountersCollector();

            collector.Collect(metadata);

            collector.Collected.Should().NotBeNull();
            collector.Collected.NodesCreated.Should().Be(1);
            collector.Collected.NodesDeleted.Should().Be(0);
            collector.Collected.RelationshipsCreated.Should().Be(2);
            collector.Collected.RelationshipsDeleted.Should().Be(0);
            collector.Collected.PropertiesSet.Should().Be(3);
            collector.Collected.LabelsAdded.Should().Be(4);
            collector.Collected.LabelsRemoved.Should().Be(0);
            collector.Collected.IndexesAdded.Should().Be(5);
            collector.Collected.IndexesRemoved.Should().Be(0);
            collector.Collected.ConstraintsAdded.Should().Be(6);
            collector.Collected.ConstraintsRemoved.Should().Be(0);
        }
        public void ShouldNotCollectIfNoValueIsGiven()
        {
            var collector = new CountersCollector();

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

            collector.Collected.Should().BeNull();
        }
        public void ShouldNotCollectIfMetadataIsNull()
        {
            var collector = new CountersCollector();

            collector.Collect(null);

            collector.Collected.Should().BeNull();
        }
        public void ShouldNotCollectIfValueIsNull()
        {
            var collector = new CountersCollector();

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

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

            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'.");
        }