Beispiel #1
0
        private void RoundtripTest(string yamlFileName)
        {
            var original = new YamlStream();

            original.Load(Yaml.ReaderFrom(yamlFileName));

            var buffer = new StringBuilder();

            original.Save(new StringWriter(buffer));

            var final = new YamlStream();

            final.Load(new StringReader(buffer.ToString()));

            var originalBuilder = new YamlDocumentStructureBuilder();

            original.Accept(originalBuilder);

            var finalBuilder = new YamlDocumentStructureBuilder();

            final.Accept(finalBuilder);

            Assert.Equal(originalBuilder.Events.Count, finalBuilder.Events.Count);

            for (var i = 0; i < originalBuilder.Events.Count; ++i)
            {
                var originalEvent = originalBuilder.Events[i];
                var finalEvent    = finalBuilder.Events[i];

                Assert.Equal(originalEvent.Type, finalEvent.Type);
                Assert.Equal(originalEvent.Value, finalEvent.Value);
            }
        }
Beispiel #2
0
        private void RoundtripTest(string yamlFileName)
        {
            YamlStream original = new YamlStream();

            original.Load(YamlFile(yamlFileName));

            StringBuilder buffer = new StringBuilder();

            original.Save(new StringWriter(buffer));

            Console.WriteLine(buffer.ToString());

            YamlStream final = new YamlStream();

            final.Load(new StringReader(buffer.ToString()));

            YamlDocumentStructureBuilder originalBuilder = new YamlDocumentStructureBuilder();

            original.Accept(originalBuilder);

            YamlDocumentStructureBuilder finalBuilder = new YamlDocumentStructureBuilder();

            final.Accept(finalBuilder);

            Console.WriteLine("The original document produced {0} events.", originalBuilder.Events.Count);
            Console.WriteLine("The final document produced {0} events.", finalBuilder.Events.Count);
            Assert.Equal(originalBuilder.Events.Count, finalBuilder.Events.Count);

            for (int i = 0; i < originalBuilder.Events.Count; ++i)
            {
                YamlNodeEvent originalEvent = originalBuilder.Events[i];
                YamlNodeEvent finalEvent    = finalBuilder.Events[i];

                Assert.Equal(originalEvent.Type, finalEvent.Type);
                //Assert.Equal(originalEvent.Tag, finalEvent.Tag);
                //Assert.Equal(originalEvent.Anchor, finalEvent.Anchor);
                Assert.Equal(originalEvent.Value, finalEvent.Value);
            }
        }
		private void RoundtripTest(string yamlFileName)
		{
			var original = new YamlStream();
			original.Load(YamlFile(yamlFileName));

			var buffer = new StringBuilder();
			original.Save(new StringWriter(buffer));

			Dump.WriteLine(buffer);

			var final = new YamlStream();
			final.Load(new StringReader(buffer.ToString()));

			var originalBuilder = new YamlDocumentStructureBuilder();
			original.Accept(originalBuilder);

			var finalBuilder = new YamlDocumentStructureBuilder();
			final.Accept(finalBuilder);

			Dump.WriteLine("The original document produced {0} events.", originalBuilder.Events.Count);
			Dump.WriteLine("The final document produced {0} events.", finalBuilder.Events.Count);
			Assert.AreEqual(originalBuilder.Events.Count, finalBuilder.Events.Count);

			for (var i = 0; i < originalBuilder.Events.Count; ++i)
			{
				var originalEvent = originalBuilder.Events[i];
				var finalEvent = finalBuilder.Events[i];

				Assert.AreEqual(originalEvent.Type, finalEvent.Type);
				Assert.AreEqual(originalEvent.Value, finalEvent.Value);
			}
		}
Beispiel #4
0
        private void RoundtripTest(string yamlFileName)
        {
            YamlStream original = new YamlStream();
            original.Load(YamlFile(yamlFileName));

            StringBuilder buffer = new StringBuilder();
            original.Save(new StringWriter(buffer));

            Console.WriteLine(buffer.ToString());

            YamlStream final = new YamlStream();
            final.Load(new StringReader(buffer.ToString()));

            YamlDocumentStructureBuilder originalBuilder = new YamlDocumentStructureBuilder();
            original.Accept(originalBuilder);

            YamlDocumentStructureBuilder finalBuilder = new YamlDocumentStructureBuilder();
            final.Accept(finalBuilder);

            Console.WriteLine("The original document produced {0} events.", originalBuilder.Events.Count);
            Console.WriteLine("The final document produced {0} events.", finalBuilder.Events.Count);
            Assert.Equal(originalBuilder.Events.Count, finalBuilder.Events.Count);

            for (int i = 0; i < originalBuilder.Events.Count; ++i)
            {
                YamlNodeEvent originalEvent = originalBuilder.Events[i];
                YamlNodeEvent finalEvent = finalBuilder.Events[i];

                Assert.Equal(originalEvent.Type, finalEvent.Type);
                //Assert.Equal(originalEvent.Tag, finalEvent.Tag);
                //Assert.Equal(originalEvent.Anchor, finalEvent.Anchor);
                Assert.Equal(originalEvent.Value, finalEvent.Value);
            }
        }