示例#1
0
        public void ShouldNotCollectIfNoValueIsGiven()
        {
            var collector = new FieldsCollector();

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

            collector.Collected.Should().BeNull();
        }
示例#2
0
        public void ShouldNotCollectIfMetadataIsNull()
        {
            var collector = new FieldsCollector();

            collector.Collect(null);

            collector.Collected.Should().BeNull();
        }
示例#3
0
        public void ShouldReturnSameCollected()
        {
            var metadata = new Dictionary <string, object> {
                { Key, new List <object> {
                      "field-1", "field-2", "field-3"
                  } }
            };
            var collector = new FieldsCollector();

            collector.Collect(metadata);

            ((IMetadataCollector)collector).Collected.Should().BeSameAs(collector.Collected);
        }
示例#4
0
        public void ShouldThrowIfValueIsOfWrongType()
        {
            var metadata = new Dictionary <string, object> {
                { Key, "some string" }
            };
            var collector = new FieldsCollector();

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

            ex.Should().BeOfType <ProtocolException>().Which
            .Message.Should()
            .Contain($"Expected '{Key}' metadata to be of type 'List<Object>', but got 'String'.");
        }
示例#5
0
        public void ShouldCollect()
        {
            var metadata = new Dictionary <string, object> {
                { Key, new List <object> {
                      "field-1", "field-2", "field-3"
                  } }
            };
            var collector = new FieldsCollector();

            collector.Collect(metadata);

            collector.Collected.Should().HaveCount(3).And
            .ContainInOrder("field-1", "field-2", "field-3");
        }