public void ShouldNotCollectIfNoValueIsGiven()
        {
            var collector = new RoutingTableCollector();

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

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

            collector.Collect(null);

            collector.Collected.Should().BeNull();
        }
        public void ShouldThrowIfValueIsOfWrongType()
        {
            var metadata = new Dictionary <string, object> {
                { RoutingTableCollector.RoutingTableKey, "some string" }
            };
            var collector = new RoutingTableCollector();

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

            ex.Should().BeOfType <ProtocolException>().Which
            .Message.Should()
            .Contain($"Expected '{RoutingTableCollector.RoutingTableKey}' metadata to be of type 'Dictionary<string, object>', but got 'String'.");
        }
        public void ShouldReturnSameCollected()
        {
            var metadata = new Dictionary <string, object> {
                { RoutingTableCollector.RoutingTableKey, new Dictionary <string, object> {
                      { "Key1", "Value1" },
                      { "Key2", "Value2" },
                      { "Key3", "Value3" }
                  } }
            };
            var collector = new RoutingTableCollector();

            collector.Collect(metadata);

            ((IMetadataCollector)collector).Collected.Should().BeSameAs(collector.Collected);
        }
        public void ShouldCollect()
        {
            var metadata = new Dictionary <string, object> {
                { RoutingTableCollector.RoutingTableKey, new Dictionary <string, object> {
                      { "Key1", "Value1" },
                      { "Key2", "Value2" },
                      { "Key3", "Value3" }
                  } }
            };
            var collector = new RoutingTableCollector();

            collector.Collect(metadata);

            collector.Collected.Should().HaveCount(3).And.Contain(new [] { new KeyValuePair <string, object>("Key1", "Value1"),
                                                                           new KeyValuePair <string, object>("Key2", "Value2"),
                                                                           new KeyValuePair <string, object>("Key3", "Value3") });
        }