<commit_before>﻿using System.IO;
using NUnit.Framework;

namespace ValveKeyValue.Test.Text
{
    class SerializationTestCase
    {
        [Test]
        public void CreatesTextDocument()
        {
            var kv = new KVObject(
                "test data",
                new[]
                {
                    new KVObject(
                        "0",
                        new[]
                        {
                            new KVObject("developer", "Valve Software"),
                            new KVObject("name", "<NAME>"),
                            new KVObject("description", "Dota 2 is a complex game where you get sworn at\nin Russian all the time.")
                        }),
                    new KVObject(
                        "1",
                        new[]
                        {
                            new KVObject("developer", "Valve Software"),
                            new KVObject("name", "<NAME> 2"),
                            new KVObject("description", "Known as \"America's #1 war-themed hat simulator\", this game lets you wear stupid items while killing people.")
                        })
                });

            string text;
            using (var ms = new MemoryStream())
            {
                KVSerializer.Serialize(ms, kv);

                ms.Seek(0, SeekOrigin.Begin);
                using (var reader = new StreamReader(ms))
                {
                    text = reader.ReadToEnd();
                }
            }

            var expected = TestDataHelper.ReadTextResource("Text.serialization_expected.vdf");
            Assert.That(text, Is.EqualTo(expected));
        }
    }
}<commit_msg>Attempt to normalize line endings for test that fails on AppVeyor<commit_after>﻿using System.IO;
using System.Text;
using NUnit.Framework;

namespace ValveKeyValue.Test.Text
{
    class SerializationTestCase
    {
        [Test]
        public void CreatesTextDocument()
        {
            var kv = new KVObject(
                "test data",
                new[]
                {
                    new KVObject(
                        "0",
                        new[]
                        {
                            new KVObject("developer", "Valve Software"),
                            new KVObject("name", "<NAME>"),
                            new KVObject("description", "Dota 2 is a complex game where you get sworn at\nin Russian all the time.")
                        }),
                    new KVObject(
                        "1",
                        new[]
                        {
                            new KVObject("developer", "Valve Software"),
                            new KVObject("name", "Team Fortress 2"),
                            new KVObject("description", "Known as \"America's #1 war-themed hat simulator\", this game lets you wear stupid items while killing people.")
                        })
                });

            string text;
            using (var ms = new MemoryStream())
            {
                KVSerializer.Serialize(ms, kv);

                ms.Seek(0, SeekOrigin.Begin);
                using (var reader = new StreamReader(ms))
                {
                    text = reader.ReadToEnd();
                }
            }

            var expected = TestDataHelper.ReadTextResource("Text.serialization_expected.vdf");
            expected = NormalizeLineEndings(expected);
            Assert.That(text, Is.EqualTo(expected));
        }

        static string NormalizeLineEndings(string text)
        {
            var builder = new StringBuilder(text.Length);
            using (var reader = new StringReader(text))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    builder.AppendLine(line);
                }
            }

            return builder.ToString();
        }
    }
}
{'fraction_non_alphanumeric': 0.09051941502773575, 'fraction_numerical': 0.0030257186081694403, 'mean_word_length': 1.079140461215933, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3434654', 'n_tokens_mistral': 952, 'n_tokens_neox': 882, 'n_words': 239}