<commit_before>﻿using System.Data;
using System.IO;

using Hprose.IO.Serializers;

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Hprose.UnitTests.IO.Serializers {
    [TestClass]
    public class DataTableSerializerTests {
        [TestMethod]
        public void TestSerializeDataTable() {
            using (MemoryStream stream = new MemoryStream()) {
                Writer writer = new Writer(stream);
                var table = MakeTable();
                writer.Serialize(table);
                writer.Serialize(table);
                Assert.AreEqual("a3{c9\"TestTable\"3{s2\"id\"s4\"name\"s3\"age\"}o0{0s5\"Mario\"i45;}o0{1s5\"Luigi\"i42;}o0{2s5\"Peach\"i28;}}r0;", ValueWriter.UTF8.GetString(stream.ToArray()));
            }
        }

        private DataTable MakeTable() {
            DataTable table = new DataTable("TestTable");

            table.Columns.Add(new DataColumn("Id", typeof(int)));
            table.Columns.Add(new DataColumn("Name", typeof(string)));
            table.Columns.Add(new DataColumn("Age", typeof(int)));

            DataRow row;

            row = table.NewRow();
            row["Id"] = 0;
            row["Name"] = "Mario";
            row["Age"] = 45;
            table.Rows.Add(row);

            row = table.NewRow();
            row["Id"] = 1;
            row["Name"] = "Luigi";
            row["Age"] = 42;
            table.Rows.Add(row);

            row = table.NewRow();
            row["Id"] = 2;
            row["Name"] = "Peach";
            row["Age"] = 28;
            table.Rows.Add(row);

            return table;
        }

    }
}
<commit_msg>Improved DataTableSerializerTests<commit_after>﻿using System.Data;
using System.IO;

using Hprose.IO.Serializers;

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Hprose.UnitTests.IO.Serializers {
    [TestClass]
    public class DataTableSerializerTests {
        [TestMethod]
        public void TestSerializeDataTable() {
            using (MemoryStream stream = new MemoryStream()) {
                Writer writer = new Writer(stream);
                var table = MakeTable();
                writer.Serialize(table);
                writer.Serialize(table);
                Assert.AreEqual("a3{c9\"TestTable\"3{s2\"id\"s4\"name\"s3\"age\"}o0{0s5\"Mario\"i45;}o0{1s5\"Luigi\"i42;}o0{2s5\"Peach\"i28;}}r0;", ValueWriter.UTF8.GetString(stream.ToArray()));
            }
        }

        private DataTable MakeTable() {
            DataTable table = new DataTable("TestTable");

            table.Columns.Add(new DataColumn("Id", typeof(int)));
            table.Columns.Add(new DataColumn("Name", typeof(string)));
            table.Columns.Add(new DataColumn("Age", typeof(int)));

            table.Rows.Add(0, "Mario", 45);
            table.Rows.Add(1, "Luigi", 42);
            table.Rows.Add(2, "Peach", 28);

            return table;
        }
    }
}

{'fraction_non_alphanumeric': 0.14781711928497765, 'fraction_numerical': 0.022000687521485048, 'mean_word_length': 2.066385669125395, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7249753', 'n_tokens_mistral': 907, 'n_tokens_neox': 863, 'n_words': 143}