From de3534625879b37236633a91db86e67d85ef22d8 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Sat, 25 Apr 2020 17:50:07 -0700 Subject: [PATCH] Improvements to yaml validation --- test/Test.Infrastructure/EqualityYamlNodeVisitor.cs | 9 ++++++++- test/Test.Infrastructure/YamlAssert.cs | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/test/Test.Infrastructure/EqualityYamlNodeVisitor.cs b/test/Test.Infrastructure/EqualityYamlNodeVisitor.cs index 1499f247..25c17e5e 100644 --- a/test/Test.Infrastructure/EqualityYamlNodeVisitor.cs +++ b/test/Test.Infrastructure/EqualityYamlNodeVisitor.cs @@ -4,6 +4,7 @@ using System; using System.CommandLine; +using System.Linq; using Tye.Serialization; using YamlDotNet.RepresentationModel; @@ -96,7 +97,13 @@ namespace Test.Infrastructure if (node.Children.Count < otherNode.Children.Count) { - throw new TyeYamlException($"Extra children in actual yaml mapping, Expected: ({node.Start.Line}, {node.Start.Column}). Actual: ({otherNode.Start.Line}, {otherNode.Start.Column})."); + throw new TyeYamlException( +$@"Extra children in actual yaml mapping: + Expected: ({node.Start.Line}, {node.Start.Column}) +{string.Join(Environment.NewLine, node.Children.Select(kvp => $" " + kvp.Key.ToString() + ": ..."))} + + Actual: ({otherNode.Start.Line}, {otherNode.Start.Column}) +{string.Join(Environment.NewLine, otherNode.Children.Select(kvp => $" " + kvp.Key.ToString() + ": ..."))}"); } } diff --git a/test/Test.Infrastructure/YamlAssert.cs b/test/Test.Infrastructure/YamlAssert.cs index 7b97a34a..44b6b1ad 100644 --- a/test/Test.Infrastructure/YamlAssert.cs +++ b/test/Test.Infrastructure/YamlAssert.cs @@ -24,7 +24,7 @@ namespace Test.Infrastructure try { - Assert.Equal(yamlStream.Documents.Count, yamlStream.Documents.Count); + Assert.Equal(yamlStream.Documents.Count, otherYamlStream.Documents.Count); for (var i = 0; i < yamlStream.Documents.Count; i++) {