<commit_before>﻿// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.DocAsCode.Common.Tests
{
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;

    using Xunit;
    using YamlDotNet.Core;

    using Microsoft.DocAsCode.Common;
    using Microsoft.DocAsCode.YamlSerialization;

    [Trait("Owner", "zhyan")]
    public class YamlSerializationTest
    {
        [Theory]
        [InlineData(" Add --globalMetadata, --globalMetadataFile and --fileMetadataFile\n")]
        [InlineData("\r\n Hello\n")]
        [InlineData("  \r\n Hello\n")]
        public void TestObjectWithStringProperty(string input)
        {
            var sw = new StringWriter();
            YamlUtility.Serialize(sw, new BasicClass { C = input });
            var yaml = sw.ToString();
            var value = YamlUtility.Deserialize<BasicClass>(new StringReader(yaml));
            Assert.NotNull(value);
            Assert.Equal(input, value.C);
        }

        [Fact]
        public void TestBasicClass()
        {
            var sw = new StringWriter();
            YamlUtility.Serialize(sw, new BasicClass { B = 1, C = "Good!" }, YamlMime.YamlMimePrefix + "Test-Yaml-Mime");
            var yaml = sw.ToString();<commit_msg>add unit test for 32-bit Unicode fails in XML comment. (#1246)<commit_after>﻿// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.DocAsCode.Common.Tests
{
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;

    using Xunit;
    using YamlDotNet.Core;

    using Microsoft.DocAsCode.Common;
    using Microsoft.DocAsCode.YamlSerialization;

    [Trait("Owner", "zhyan")]
    public class YamlSerializationTest
    {
        [Theory]
        [InlineData(" Add --globalMetadata, --globalMetadataFile and --fileMetadataFile\n")]
        [InlineData("\r\n Hello\n")]
        [InlineData("  \r\n Hello\n")]
        [InlineData("True")]
        [InlineData("true")]
        [InlineData("TRUE")]
        [InlineData("False")]
        [InlineData("false")]
        [InlineData("FALSE")]
        [InlineData("Null")]
        [InlineData("null")]
        [InlineData("NULL")]
        public void TestObjectWithStringProperty(string input)
        {
            var sw = new StringWriter();
            YamlUtility.Serialize(sw, new BasicClass { C = input });
            var yaml = sw.ToString();
            var value = YamlUtility.Deserialize<BasicClass>(new StringReader(yaml));
            Assert.NotNull(value);
            Assert.Equal(input, value.C);
        }

        [Fact(Skip = "Not work in YamlDotNet 3.9")]
        public void TestNotWorkInYamlDotNet39()
        {
            const string Text = "😄";
            var sw = new StringWriter();
            YamlUtility.Serialize(sw, new BasicClass { C = Text });
            var yaml = sw.ToString();
            var value = YamlUtility.Deserialize<BasicClass>(new StringReader(yaml));
            Assert.NotNull(value);
            Assert.Equal(Text, value.C);
        }

        [Fact]
        public void TestBasicClass()
        {
            var sw = new StringWriter();
            YamlUtility.Serialize(sw, new BasicClass { B = 1, C = "Good!" }, YamlMime.YamlMimePrefix + "Test-Yaml-Mime");
            var yaml = sw.ToString();
{'fraction_non_alphanumeric': 0.1190271816881259, 'fraction_numerical': 0.0034334763948497852, 'mean_word_length': 2.3295238095238093, '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': '5999365', 'n_tokens_mistral': 982, 'n_tokens_neox': 992, 'n_words': 248}