CreateYamlNode() public static méthode

public static CreateYamlNode ( string yamlText ) : YamlMappingNode
yamlText string
Résultat YamlMappingNode
Exemple #1
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);
        }
        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);
        }
        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);
        }
Exemple #4
0
        public void DeserializeChild_PropertySpecified_DeserializesChild()
        {
            // Arrange
            var          errorReporter = new Mock <IErrorReporter>();
            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, errorReporter.Object);

            // Assert
            Assert.Equal(TimeSpan.FromMinutes(5), aggregation.Interval);
        }
Exemple #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);
            });
        }
Exemple #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);
            });
        }
Exemple #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));
        }
Exemple #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);
        }
Exemple #9
0
 public void ReportWarning_EmptyMessage_ThrowsException()
 {
     Assert.Throws <ArgumentException>(
         () => _errorReporter.ReportWarning(YamlUtils.CreateYamlNode("name: promitor"), string.Empty));
 }
Exemple #10
0
 public void ReportError_NullMessage_ThrowsException()
 {
     Assert.Throws <ArgumentException>(
         () => _errorReporter.ReportError(YamlUtils.CreateYamlNode("name: promitor"), null));
 }