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

namespace Atata.Tests
{
    [TestFixture]
    [SetCulture("en-us")]
    public class TermResolverTest
    {
        [TermSettings(StringFormat = ">>{0}")]
        public enum Options
        {
            [Term(TermFormat.TitleWithColon)]
            A,
            B,
            C,
            [Term(TermFormat.LowerCase, StringFormat = "--{0}--")]
            D
        }

        [TestCaseSource(typeof(TermResolverStringFormatTestCaseSource))]
        public void TermResolver_StringFormat(object value, string format, string expectedFormattedValue)
        {
            TermOptions options = new TermOptions { StringFormat = format };
            string formatted = TermResolver.ToString(value, options);

            Assert.That(formatted, Is.EqualTo(expectedFormattedValue));

            object unformatted = TermResolver.FromString(formatted, value.GetType(), options);
            Assert.That(unformatted, Is.EqualTo(value));
        }

        private class TermResolverStringFormatTestCaseSource : TestCaseDataSource
        {
            public TermResolverStringFormatTestCaseSource()
            {
                Add("test string");
                Add(50);<commit_msg>Add test cases to TermResolverTest<commit_after>﻿using NUnit.Framework;
using System;
using System.Globalization;

namespace Atata.Tests
{
    [TestFixture]
    [SetCulture("en-us")]
    public class TermResolverTest
    {
        [TermSettings(StringFormat = ">>{0}")]
        public enum Options
        {
            [Term(TermFormat.TitleWithColon)]
            A,
            B,
            C,
            [Term(TermFormat.LowerCase, StringFormat = "--{0}--")]
            D
        }

        [TestCaseSource(typeof(TermResolverStringFormatTestCaseSource))]
        public void TermResolver_StringFormat(object value, string format, string expectedFormattedValue)
        {
            TermOptions options = new TermOptions { StringFormat = format };
            string formatted = TermResolver.ToString(value, options);

            Assert.That(formatted, Is.EqualTo(expectedFormattedValue));

            object unformatted = TermResolver.FromString(formatted, value.GetType(), options);
            Assert.That(unformatted, Is.EqualTo(value));
        }

        private class TermResolverStringFormatTestCaseSource : TestCaseDataSource
        {
            public TermResolverStringFormatTestCaseSource()
            {
                Add("test string");
                Add('a');
                Add(true);
                Add((byte)126);
                Add(50);
{'fraction_non_alphanumeric': 0.09493192133131619, 'fraction_numerical': 0.00416036308623298, 'mean_word_length': 2.2021791767554477, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5813376', 'n_tokens_mistral': 664, 'n_tokens_neox': 646, 'n_words': 132}