Exemple #1
0
        public void ShouldCollect()
        {
            var metadata = new Dictionary <string, object>
            {
                {
                    Key, new List <object>
                    {
                        new Dictionary <string, object>
                        {
                            { "code", "code1" },
                            { "title", "title1" },
                            { "description", "description1" },
                            { "severity", "severity1" },
                            {
                                "position", new Dictionary <string, object>
                                {
                                    { "offset", 1L },
                                    { "line", 2L },
                                    { "column", 3L }
                                }
                            }
                        }
                    }
                }
            };
            var collector = new NotificationsCollector();

            collector.Collect(metadata);

            collector.Collected.Should().BeEquivalentTo(new[]
            {
                new Notification("code1", "title1", "description1",
                                 new InputPosition(1, 2, 3), "severity1")
            });
        }
Exemple #2
0
        public void ShouldReturnSameCollected()
        {
            var metadata = new Dictionary <string, object>
            {
                {
                    Key, new List <object>
                    {
                        new Dictionary <string, object>
                        {
                            { "code", "code1" },
                            { "title", "title1" },
                            { "description", "description1" },
                            { "severity", "severity1" },
                            {
                                "position", new Dictionary <string, object>
                                {
                                    { "offset", 1L },
                                    { "line", 2L },
                                    { "column", 3L }
                                }
                            }
                        }
                    }
                }
            };
            var collector = new NotificationsCollector();

            collector.Collect(metadata);

            ((IMetadataCollector)collector).Collected.Should().BeSameAs(collector.Collected);
        }
Exemple #3
0
        public void ShouldNotCollectIfNoValueIsGiven()
        {
            var collector = new NotificationsCollector();

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

            collector.Collected.Should().BeNull();
        }
Exemple #4
0
        public void ShouldNotCollectIfMetadataIsNull()
        {
            var collector = new NotificationsCollector();

            collector.Collect(null);

            collector.Collected.Should().BeNull();
        }
Exemple #5
0
        public void ShouldNotCollectIfValueIsNull()
        {
            var collector = new NotificationsCollector();

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

            collector.Collected.Should().BeNull();
        }
Exemple #6
0
        public void ShouldThrowIfValueIsOfWrongType()
        {
            var metadata = new Dictionary <string, object> {
                { Key, 3 }
            };
            var collector = new NotificationsCollector();

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