Пример #1
0
        public void HasErrors_AfterErrorReported_True()
        {
            // Arrange
            var node = YamlUtils.CreateYamlNode("name: promitor");

            _errorReporter.ReportError(node, "Test error message");

            // Act
            var hasErrors = _errorReporter.HasErrors;

            // Assert
            Assert.True(hasErrors);
        }
Пример #2
0
        public void HasErrors_AfterWarningReported_False()
        {
            // Arrange
            var node = YamlUtils.CreateYamlNode("name: promitor");

            _errorReporter.ReportWarning(node, "Test warning");

            // Act
            var hasErrors = _errorReporter.HasErrors;

            // Assert
            Assert.False(hasErrors);
        }
Пример #3
0
        public void DeserializeChild_PropertyNotSpecified_Null()
        {
            // Arrange
            var errorReporter = new Mock <IErrorReporter>();
            var node          = YamlUtils.CreateYamlNode(@"time: 00:05:30");
            var deserializer  = new AggregationDeserializer(NullLogger <AggregationDeserializer> .Instance);

            // Act
            var aggregation = node.DeserializeChild("aggregation", deserializer, errorReporter.Object);

            // Assert
            Assert.Null(aggregation);
        }
Пример #4
0
        public void DeserializeChild_PropertySpecified_DeserializesChild()
        {
            // Arrange
            const string yamlText =
                @"aggregation:
    interval: 00:05:00";
            var node         = YamlUtils.CreateYamlNode(yamlText);
            var deserializer = new AggregationDeserializer(NullLogger <AggregationDeserializer> .Instance);

            // Act
            var aggregation = node.DeserializeChild("aggregation", deserializer);

            // Assert
            Assert.Equal(TimeSpan.FromMinutes(5), aggregation.Interval);
        }
Пример #5
0
        public void ReportWarning_AfterWarningReported_AddsWarning()
        {
            // Arrange
            var node = YamlUtils.CreateYamlNode("name: promitor");

            // Act
            _errorReporter.ReportWarning(node, "Test warning message");

            // Assert
            Assert.Collection(_errorReporter.Messages,
                              m =>
            {
                Assert.Equal(node, m.Node);
                Assert.Equal(MessageType.Warning, m.MessageType);
                Assert.Equal("Test warning message", m.Message);
            });
        }
Пример #6
0
        public void ReportError_AfterErrorReported_AddsError()
        {
            // Arrange
            var node = YamlUtils.CreateYamlNode("name: promitor");

            // Act
            _errorReporter.ReportError(node, "Test error message");

            // Assert
            Assert.Collection(_errorReporter.Messages,
                              m =>
            {
                Assert.Equal(node, m.Node);
                Assert.Equal(MessageType.Error, m.MessageType);
                Assert.Equal("Test error message", m.Message);
            });
        }
Пример #7
0
        public void Messages_MultipleMessagesAdded_ReturnedInOrderOfLineNumber()
        {
            // Arrange
            var node = YamlUtils.CreateYamlNode(
                @"firstNode: one
secondNode: two
thirdNode: three");

            _errorReporter.ReportWarning(node.Children["secondNode"], "second");
            _errorReporter.ReportError(node.Children["firstNode"], "first");
            _errorReporter.ReportWarning(node.Children["thirdNode"], "third");

            // Act
            var messages = _errorReporter.Messages;

            // Assert
            Assert.Collection(messages,
                              m => Assert.Equal("first", m.Message),
                              m => Assert.Equal("second", m.Message),
                              m => Assert.Equal("third", m.Message));
        }
Пример #8
0
        public void GetDictionary_PropertySpecified_DeserializesDictionary()
        {
            // Arrange
            const string yamlText =
                @"labels:
    env: production
    tier: web";
            var node = YamlUtils.CreateYamlNode(yamlText);

            // Act
            var labels = node.GetDictionary("labels");

            // Assert
            var expected = new Dictionary <string, string>
            {
                { "env", "production" },
                { "tier", "web" }
            };

            Assert.Equal(expected, labels);
        }
Пример #9
0
 public void ReportWarning_EmptyMessage_ThrowsException()
 {
     Assert.Throws <ArgumentException>(
         () => _errorReporter.ReportWarning(YamlUtils.CreateYamlNode("name: promitor"), string.Empty));
 }
Пример #10
0
 public void ReportError_NullMessage_ThrowsException()
 {
     Assert.Throws <ArgumentException>(
         () => _errorReporter.ReportError(YamlUtils.CreateYamlNode("name: promitor"), null));
 }