<commit_before>﻿// Copyright (c) <NAME>. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Collections.Immutable;
using Xunit;

namespace Core2D.UnitTests
{
    public class DatabaseTests
    {
        [Fact]
        [Trait("Core2D", "Data")]
        public void Inherits_From_ObservableObject()
        {
            var target = new Database();
            Assert.True(target is ObservableObject);
        }

        [Fact]
        [Trait("Core2D", "Data")]
        public void FromFields_Existing_Record_Ids()
        {
            var fields = new string[][]
            {
                new string[] { "Id", "Column0", "Column1", "Column2" },
                new string[] { "75080d72-734d-4187-a38f-9860df375a2a", "Row0Value0", "Row0Value1", "Row0Value2" },
                new string[] { "547fe8cf-b3ab-4abb-843b-acb3df0f7ad1", "Row1Value0", "Row1Value1", "Row1Value2" }
            };

            var target = Database.FromFields("Test", fields, "Id");

            Assert.Equal("Id", target.IdColumnName);

            Assert.Equal(4, target.Columns.Length);

            Assert.Equal("Id", target.Columns[0].Name);
            Assert.Equal("Column0", target.Columns[1].Name);
            Assert.Equal("Column1", target.Columns[2].Name);
            Assert.Equal("Column2", target.Columns[3].Name);

            Assert.Equal(2, target.Records.Length);

            Assert.Equal("75080d72-734d-4187-a38f-9860df375a2a", target.Records[0].Id.ToString());
            Assert.Equal("547fe8cf-b3ab-4abb-843b-acb3df0f7ad1", target.Records[1].Id.ToString());
        }

        [Fact]
        [Trait("Core2D", "Data")]
        public void FromFields_New_Record_Ids()
        {
            var fields = new string[][]
            {
                new string[] { "Column0", "Column1", "Column2" },
                new string[] { "Row0Value0", "Row0Value1", "Row0Value2" },
                new string[] { "Row1Value0", "Row1Value1", "Row1Value2" }
            };

            var target = Database.FromFields("Test", fields);

            Assert.Equal(3, target.Columns.Length);

            Assert.Equal("Column0", target.Columns[0].Name);
            Assert.Equal("Column1", target.Columns[1].Name);
            Assert.Equal("Column2", target.Columns[2].Name);

            Assert.Equal(2, target.Records.Length);

            Assert.Equal("Row0Value0", target.Records[0].Values[0].Content);
            Assert.Equal("Row0Value1", target.Records[0].Values[1].Content);
            Assert.Equal("Row0Value2", target.Records[0].Values[2].Content);

            Assert.Equal("Row1Value0", target.Records[1].Values[0].Content);
            Assert.Equal("Row1Value1", target.Records[1].Values[1].Content);
            Assert.Equal("Row1Value2", target.Records[1].Values[2].Content);
        }

        [Fact]
        [Trait("Core2D", "Data")]
        public void Update_Destination()
        {
            var destinationFields = new string[][]
            {
                new string[] { "Column0", "Column1", "Column2" },
                new string[] { "Row0Value0", "Row0Value1", "Row0Value2" }, 
                new string[] { "Row1Value0", "Row1Value1", "Row1Value2" },
                new string[] { "Row2Value0", "Row2Value1", "Row2Value2" }
            };
<commit_msg>Added new tests<commit_after>﻿// Copyright (c) <NAME>. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Collections.Immutable;
using Xunit;

namespace Core2D.UnitTests
{
    public class DatabaseTests
    {
        [Fact]
        [Trait("Core2D", "Data")]
        public void Inherits_From_ObservableObject()
        {
            var target = new Database();
            Assert.True(target is ObservableObject);
        }

        [Fact]
        [Trait("Core2D", "Data")]
        public void Columns_Not_Null()
        {
            var target = new Database();
            Assert.NotNull(target.Columns);
        }

        [Fact]
        [Trait("Core2D", "Data")]
        public void Records_Not_Null()
        {
            var target = new Database();
            Assert.NotNull(target.Records);
        }

        [Fact]
        [Trait("Core2D", "Data")]
        public void FromFields_Existing_Record_Ids()
        {
            var fields = new string[][]
            {
                new string[] { "Id", "Column0", "Column1", "Column2" },
                new string[] { "75080d72-734d-4187-a38f-9860df375a2a", "Row0Value0", "Row0Value1", "Row0Value2" },
                new string[] { "547fe8cf-b3ab-4abb-843b-acb3df0f7ad1", "Row1Value0", "Row1Value1", "Row1Value2" }
            };

            var target = Database.FromFields("Test", fields, "Id");

            Assert.Equal("Id", target.IdColumnName);

            Assert.Equal(4, target.Columns.Length);

            Assert.Equal("Id", target.Columns[0].Name);
            Assert.Equal("Column0", target.Columns[1].Name);
            Assert.Equal("Column1", target.Columns[2].Name);
            Assert.Equal("Column2", target.Columns[3].Name);

            Assert.Equal(2, target.Records.Length);

            Assert.Equal("75080d72-734d-4187-a38f-9860df375a2a", target.Records[0].Id.ToString());
            Assert.Equal("547fe8cf-b3ab-4abb-843b-acb3df0f7ad1", target.Records[1].Id.ToString());
        }

        [Fact]
        [Trait("Core2D", "Data")]
        public void FromFields_New_Record_Ids()
        {
            var fields = new string[][]
            {
                new string[] { "Column0", "Column1", "Column2" },
                new string[] { "Row0Value0", "Row0Value1", "Row0Value2" },
                new string[] { "Row1Value0", "Row1Value1", "Row1Value2" }
            };

            var target = Database.FromFields("Test", fields);

            Assert.Equal(3, target.Columns.Length);

            Assert.Equal("Column0", target.Columns[0].Name);
            Assert.Equal("Column1", target.Columns[1].Name);
            Assert.Equal("Column2", target.Columns[2].Name);

            Assert.Equal(2, target.Records.Length);

            Assert.Equal("Row0Value0", target.Records[0].Values[0].Content);
            Assert.Equal("Row0Value1", target.Records[0].Values[1].Content);
            Assert.Equal("Row0Value2", target.Records[0].Values[2].Content);

            Assert.Equal("Row1Value0", target.Records[1].Values[0].Content);
            Assert.Equal("Row1Value1", target.Records[1].Values[1].Content);
            Assert.Equal("Row1Value2", target.Records[1].Values[2].Content);
        }

        [Fact]
        [Trait("Core2D", "Data")]
        public void Update_Destination()
        {
            var destinationFields = new string[][]
            {
                new string[] { "Column0", "Column1", "Column2" },
                new string[] { "Row0Value0", "Row0Value1", "Row0Value2" },
                new string[] { "Row1Value0", "Row1Value1", "Row1Value2" },
                new string[] { "Row2Value0", "Row2Value1", "Row2Value2" }
            };

{'fraction_non_alphanumeric': 0.15023210015473343, 'fraction_numerical': 0.048952032634688426, 'mean_word_length': 2.143236074270557, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4929188', 'n_tokens_mistral': 2239, 'n_tokens_neox': 2123, 'n_words': 378}