<commit_before>﻿
namespace Sieve.NET.Core.Tests
{
    using System;
    using System.Collections.Generic;
    using System.Linq.Expressions;

    using FluentAssertions;
    using Xunit;
    using Xunit.Extensions;

    public class EqualitySieveTests
    {
        public class ToExpressionTests
        {
            [Fact]
            public void SingleValue_MatchesOnlyThatValue()
            {
                var aBusinessObjectWithAnIntOf1 = new ABusinessObject { AnInt = 1 };
                var aBusinessObjectWithAnIntOf2 = new ABusinessObject { AnInt = 2 };
                var aBusinessObjectWithAnIntOf3 = new ABusinessObject { AnInt = 3 };

                var sieve = new EqualitySieve<ABusinessObject, int>().ForProperty("AnInt").ForValue(1);

                var sut = sieve.ToExpression();

                sut.Compile().Invoke(aBusinessObjectWithAnIntOf1).Should().BeTrue();
                sut.Compile().Invoke(aBusinessObjectWithAnIntOf2).Should().BeFalse();
                sut.Compile().Invoke(aBusinessObjectWithAnIntOf3).Should().BeFalse();
            }
        }

        public class ToCompiledExpressionTests
        {
            [Fact]
            public void ToCompiledExpression_ReturnsCompiledExpression()
            {
                var aBusinessObjectWithAnIntOf1 = new ABusinessObject { AnInt = 1 };
                var aBusinessObjectWithAnIntOf2 = new ABusinessObject { AnInt = 2 };
                var aBusinessObjectWithAnIntOf3 = new ABusinessObject { AnInt = 3 };

                var sut = new EqualitySieve<ABusinessObject, int>().ForProperty("AnInt").ForValue(1).ToCompiledExpression();

                sut.Invoke(aBusinessObjectWithAnIntOf1).Should().BeTrue();
                sut.Invoke(aBusinessObjectWithAnIntOf2).Should().BeFalse();
                sut.Invoke(aBusinessObjectWithAnIntOf3).Should().BeFalse();

                //TODO:
            }
        }
        public class ImplicitExpressionConversionTests
        {
            [Fact]
            public void SingleValue_ImplicitConversionToFunc_WorksTheSameAsCompiledExpression()
            {
                var aBusinessObjectWithAnIntOf1 = new ABusinessObject { AnInt = 1 };
                var aBusinessObjectWithAnIntOf2 = new ABusinessObject { AnInt = 2 };
                var aBusinessObjectWithAnIntOf3 = new ABusinessObject { AnInt = 3 };

                //Implicit conversion means there's no call to ToExpression() necessary here.

                Func<ABusinessObject, bool> sut =
                    new EqualitySieve<ABusinessObject, int>().ForProperty("AnInt").ForValue(1);

                sut.Invoke(aBusinessObjectWithAnIntOf1).Should().BeTrue();
                sut.Invoke(aBusinessObjectWithAnIntOf2).Should().BeFalse();
                sut.Invoke(aBusinessObjectWithAnIntOf3).Should().BeFalse();

                //TODO:
            }

            [Fact]
            public void SingleValue_ImplicitConversionToExpression_WorksTheSameAsToExpression()
            {
                var aBusinessObjectWithAnIntOf1 = new ABusinessObject { AnInt = 1 };
                var aBusinessObjectWithAnIntOf2 = new ABusinessObject { AnInt = 2 };
                var aBusinessObjectWithAnIntOf3 = new ABusinessObject { AnInt = 3 };

                //Implicit conversion means there's no call to ToExpression() necessary here.

                Expression<Func<ABusinessObject, bool>> sut =
                    new EqualitySieve<ABusinessObject, int>().ForProperty("AnInt").ForValue(1);

                sut.Compile().Invoke(aBusinessObjectWithAnIntOf1).Should().BeTrue();
                sut.Compile().Invoke(aBusinessObjectWithAnIntOf2).Should().BeFalse();
                sut.Compile().Invoke(aBusinessObjectWithAnIntOf3).Should().BeFalse();
            }
            //TODO
        }
        public class ForPropertyTests
        {
            [Fact]
            public void ForProperty_SetsProperty()<commit_msg>Minor comment edits.<commit_after>﻿
namespace Sieve.NET.Core.Tests
{
    using System;
    using System.Collections.Generic;
    using System.Linq.Expressions;

    using FluentAssertions;
    using Xunit;
    using Xunit.Extensions;

    public class EqualitySieveTests
    {
        public class ToExpressionTests
        {
            [Fact]
            public void SingleValue_MatchesOnlyThatValue()
            {
                var aBusinessObjectWithAnIntOf1 = new ABusinessObject { AnInt = 1 };
                var aBusinessObjectWithAnIntOf2 = new ABusinessObject { AnInt = 2 };
                var aBusinessObjectWithAnIntOf3 = new ABusinessObject { AnInt = 3 };

                var sieve = new EqualitySieve<ABusinessObject, int>().ForProperty("AnInt").ForValue(1);

                var sut = sieve.ToExpression();

                sut.Compile().Invoke(aBusinessObjectWithAnIntOf1).Should().BeTrue();
                sut.Compile().Invoke(aBusinessObjectWithAnIntOf2).Should().BeFalse();
                sut.Compile().Invoke(aBusinessObjectWithAnIntOf3).Should().BeFalse();
            }
        }

        public class ToCompiledExpressionTests
        {
            [Fact]
            public void ToCompiledExpression_ReturnsCompiledExpression()
            {
                var aBusinessObjectWithAnIntOf1 = new ABusinessObject { AnInt = 1 };
                var aBusinessObjectWithAnIntOf2 = new ABusinessObject { AnInt = 2 };
                var aBusinessObjectWithAnIntOf3 = new ABusinessObject { AnInt = 3 };

                var sut = new EqualitySieve<ABusinessObject, int>().ForProperty("AnInt").ForValue(1).ToCompiledExpression();

                sut.Invoke(aBusinessObjectWithAnIntOf1).Should().BeTrue();
                sut.Invoke(aBusinessObjectWithAnIntOf2).Should().BeFalse();
                sut.Invoke(aBusinessObjectWithAnIntOf3).Should().BeFalse();

            }
        }
        public class ImplicitExpressionConversionTests
        {
            [Fact]
            public void SingleValue_ImplicitConversionToFunc_WorksTheSameAsCompiledExpression()
            {
                var aBusinessObjectWithAnIntOf1 = new ABusinessObject { AnInt = 1 };
                var aBusinessObjectWithAnIntOf2 = new ABusinessObject { AnInt = 2 };
                var aBusinessObjectWithAnIntOf3 = new ABusinessObject { AnInt = 3 };

                //Implicit conversion means there's no call to ToCompiledExpression() necessary here.

                Func<ABusinessObject, bool> sut =
                    new EqualitySieve<ABusinessObject, int>().ForProperty("AnInt").ForValue(1);

                sut.Invoke(aBusinessObjectWithAnIntOf1).Should().BeTrue();
                sut.Invoke(aBusinessObjectWithAnIntOf2).Should().BeFalse();
                sut.Invoke(aBusinessObjectWithAnIntOf3).Should().BeFalse();

            }

            [Fact]
            public void SingleValue_ImplicitConversionToExpression_WorksTheSameAsToExpression()
            {
                var aBusinessObjectWithAnIntOf1 = new ABusinessObject { AnInt = 1 };
                var aBusinessObjectWithAnIntOf2 = new ABusinessObject { AnInt = 2 };
                var aBusinessObjectWithAnIntOf3 = new ABusinessObject { AnInt = 3 };

                //Implicit conversion means there's no call to ToExpression() necessary here.

                Expression<Func<ABusinessObject, bool>> sut =
                    new EqualitySieve<ABusinessObject, int>().ForProperty("AnInt").ForValue(1);

                sut.Compile().Invoke(aBusinessObjectWithAnIntOf1).Should().BeTrue();
                sut.Compile().Invoke(aBusinessObjectWithAnIntOf2).Should().BeFalse();
                sut.Compile().Invoke(aBusinessObjectWithAnIntOf3).Should().BeFalse();
            }
        }
        public class ForPropertyTests
        {
            [Fact]
            public void ForProperty_SetsProperty()
{'fraction_non_alphanumeric': 0.08829542550472783, 'fraction_numerical': 0.010222335803731152, 'mean_word_length': 2.1778319123020706, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '2397547', 'n_tokens_mistral': 2222, 'n_tokens_neox': 1983, 'n_words': 362}