<commit_before>﻿using IniParser.Model;
using IniParser.Parser;
using NUnit.Framework;
using IniParser.Exceptions;


namespace IniFileParser.Tests.Unit.Parser
{
    [TestFixture]
    public class ParserTests
    {

        string iniFileStr =
@";comment for section1
[section1]

;comment for key1
key1 = value1
key2 = value5

[section2]

;comment for myKey1
mykey1 = value1
";
   
        [Test]
        public void parse_ini_string_with_default_configuration()
        {
            var parser = new IniDataParser();
            IniData data = parser.Parse(iniFileStr);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Sections.Count, Is.EqualTo(2));
            var section1 = data.Sections.GetSectionData("section1");

            Assert.That(section1, Is.Not.Null);
            Assert.That(section1.SectionName, Is.EqualTo("section1"));
            Assert.That(section1.Comments, Is.Not.Empty);
            Assert.That(section1.Comments.Count, Is.EqualTo(1));

            Assert.That(section1.Keys, Is.Not.Null);
            Assert.That(section1.Keys.Count, Is.EqualTo(2));
            Assert.That(section1.Keys.GetKeyData("key1"), Is.Not.Null);
            Assert.That(section1.Keys["key1"], Is.EqualTo("value1"));
            Assert.That(section1.Keys.GetKeyData("key2"), Is.Not.Null);
            Assert.That(section1.Keys["key2"], Is.EqualTo("value5"));
        }
         
        string iniFileStrCustom = 
@"#comment for section1
<section1>

#comment for key1
key1 = value1
key2 = value5

<section2>

#comment for myKey1
mykey1 = value1
"; 
       
        [Test]
        public void parse_ini_string_with_custom_configuration()
        {
            var parser = new IniDataParser();
			
			IniParser.Model.Configuration.IIniParserConfiguration config = parser.Configuration;
			
			config.CommentString = "#";
			config.SectionStartChar = '<';
			config.SectionEndChar = '>';
			<commit_msg>Fix some errors when integrating from development<commit_after>﻿using IniParser.Model;
using IniParser.Parser;
using NUnit.Framework;
using IniParser.Exceptions;


namespace IniFileParser.Tests.Unit.Parser
{
    [TestFixture]
    public class ParserTests
    {

        string iniFileStr =
@";comment for section1
[section1]

;comment for key1
key1 = value1
key2 = value5

[section2]

;comment for myKey1
mykey1 = value1
";
   
        [Test]
        public void parse_ini_string_with_default_configuration()
        {
            var parser = new IniDataParser();
            IniData data = parser.Parse(iniFileStr);

            Assert.That(data, Is.Not.Null);
            Assert.That(data.Sections.Count, Is.EqualTo(2));
            var section1 = data.Sections.GetSectionData("section1");

            Assert.That(section1, Is.Not.Null);
            Assert.That(section1.SectionName, Is.EqualTo("section1"));
            Assert.That(section1.Comments, Is.Not.Empty);
            Assert.That(section1.Comments.Count, Is.EqualTo(1));

            Assert.That(section1.Keys, Is.Not.Null);
            Assert.That(section1.Keys.Count, Is.EqualTo(2));
            Assert.That(section1.Keys.GetKeyData("key1"), Is.Not.Null);
            Assert.That(section1.Keys["key1"], Is.EqualTo("value1"));
            Assert.That(section1.Keys.GetKeyData("key2"), Is.Not.Null);
            Assert.That(section1.Keys["key2"], Is.EqualTo("value5"));
        }
         
        string iniFileStrCustom = 
@"#comment for section1
<section1>

#comment for key1
key1 = value1
key2 = value5

<section2>

#comment for myKey1
mykey1 = value1
"; 
       
        [Test]
        public void parse_ini_string_with_custom_configuration()
        {
            var parser = new IniDataParser();
			
			IniParser.Model.Configuration.IniParserConfiguration config = parser.Configuration;
			
			config.CommentString = "#";
			config.SectionStartChar = '<';
			config.SectionEndChar = '>';
			
{'fraction_non_alphanumeric': 0.11918828666837915, 'fraction_numerical': 0.022604675057796043, 'mean_word_length': 2.6701225259189445, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3515416', 'n_tokens_mistral': 1243, 'n_tokens_neox': 1198, 'n_words': 214}