<commit_before>﻿using System;
using System.Collections.Generic;
using Xunit;
using FireworksNet.Selection;
using FireworksNet.Model;

namespace FireworksNet.Tests.Selection
{
    public class BestSelectorTests
    {
        private int samplingNumber;
        private int countFireworks;
        private Func<IEnumerable<Firework>, Firework> getBest;
        private IEnumerable<Firework> allFireworks;
        private BestSelector bestSelector;

        public BestSelectorTests()
        {
            this.samplingNumber = SelectorTestsHelper.SamplingNumber;
            this.countFireworks = SelectorTestsHelper.CountFireworks;
            this.getBest = SelectorTestsHelper.GetBest;
            this.allFireworks = SelectorTestsHelper.Fireworks;
            this.bestSelector = new BestSelector(this.getBest, this.samplingNumber);
        }

        [Fact]
        public void Select_Missing2ndParam_ReturnsEqualFireworks()
        {
            IEnumerable<Firework> expectedFireworks = SelectorTestsHelper.BestFireworks;

            IEnumerable<Firework> resultingFireworks = bestSelector.Select(this.allFireworks);

            Assert.NotSame(expectedFireworks, resultingFireworks);
            Assert.Equal(expectedFireworks, resultingFireworks);
        }

        [Fact]
        public void Select_Missing2ndParam_ReturnsNonEqualFireworks()
        {
            IEnumerable<Firework> expectedFireworks = SelectorTestsHelper.NonBestFireworks;

            IEnumerable<Firework> resultingFireworks = bestSelector.Select(this.allFireworks);

            Assert.NotSame(expectedFireworks, resultingFireworks);
            Assert.NotEqual(expectedFireworks, resultingFireworks);
        }

        [Fact]
        public void Select_PresentAllParam_ReturnsEqualFireworks()
        {
            IEnumerable<Firework> expectedFireworks = SelectorTestsHelper.BestFireworks;
            this.samplingNumber++;

            IEnumerable<Firework> resultingFireworks = bestSelector.Select(this.allFireworks, this.samplingNumber);

            Assert.NotSame(expectedFireworks, resultingFireworks);
            Assert.Equal(expectedFireworks, resultingFireworks);
        }

        [Fact]
        public void Select_PresentAllParam_ReturnsNonEqualFireworks()
        {
            IEnumerable<Firework> expectedFireworks = SelectorTestsHelper.NonBestFireworks;
            this.samplingNumber++;

            IEnumerable<Firework> resultingFireworks = bestSelector.Select(this.allFireworks, this.samplingNumber);

            Assert.NotSame(expectedFireworks, resultingFireworks);
            Assert.NotEqual(expectedFireworks, resultingFireworks);
        }

        [Fact]
        public void Select_NullAs1stParam_ExceptionThrown()
        {
            IEnumerable<Firework> currentFireworks = null;
            string exceptionMessage = "Value cannot be null.\r\nParameter name: from";

            Exception actualException = Assert.Throws<ArgumentNullException>(() => this.bestSelector.Select(currentFireworks));

            Assert.NotNull(actualException);
            Assert.Equal(exceptionMessage, actualException.Message);
        }

        [Fact]
        public void Select_NegativeNumberAs2ndParam_ExceptionThrown()
        {
            string exceptionMessage = "Specified argument was out of the range of valid values.\r\nParameter name: numberToSelect";
            this.samplingNumber = -1;

            Exception actualException = Assert.Throws<ArgumentOutOfRangeException>(() => this.bestSelector.Select(this.allFireworks, this.samplingNumber));
          
            Assert.NotNull(actualException);
            Assert.Equal(exceptionMessage, actualException.Message);
        }

        [Fact]
        public void Select_GreatNumberAs2ndParam_ExceptionThrown()
        {
            string exceptionMessage = "Specified argument was out of the range of valid values.\r\nParameter name: numberToSelect";
            this.samplingNumber = this.countFireworks + 1;

            Exception actualException = Assert.Throws<ArgumentOutOfRangeException>(() => this.bestSelector.Select(this.allFireworks, this.samplingNumber));

            Assert.NotNull(actualException);
            Assert.Equal(exceptionMessage, actualException.Message);
        }

        [Fact]
        public void Select_CountFireworksEqual2ndParam_ReturnsEqualFireworks()
        {
            IEnumerable<Firework> expectedFireworks = this.allFireworks;
            this.samplingNumber = this.countFireworks;

            IEnumerable<Firework> resultingFireworks = bestSelector.Select(this.allFireworks, this.samplingNumber);

            Assert.NotSame(expectedFireworks, resultingFireworks);
            Assert.Equal(expectedFireworks, resultingFireworks);
        }

        [Fact]
        public void Select_NullAs2ndParam_ReturnsEmptyCollectionFireworks()
        {
            IEnumerable<Firework> expectedFireworks = new List<Firework>();
            this.samplingNumber = 0;

            IEnumerable<Firework> resultingFireworks = bestSelector.Select(this.allFireworks, this.samplingNumber);

            Assert.NotSame(expectedFireworks, resultingFireworks);
            Assert.Equal(expectedFireworks, resultingFireworks);
        }
    }
}<commit_msg>Change tests for BestSeletor<commit_after>﻿using System;
using System.Collections.Generic;
using Xunit;
using FireworksNet.Selection;
using FireworksNet.Model;

namespace FireworksNet.Tests.Selection
{
    public class BestSelectorTests
    {
        private readonly int samplingNumber;
        private readonly int countFireworks;
        private readonly Func<IEnumerable<Firework>, Firework> getBest;
        private readonly IEnumerable<Firework> allFireworks;
        private readonly BestSelector bestSelector;

        public BestSelectorTests()
        {
            this.samplingNumber = SelectorTestsHelper.SamplingNumber;
            this.countFireworks = SelectorTestsHelper.CountFireworks;
            this.getBest = SelectorTestsHelper.GetBest;
            this.allFireworks = SelectorTestsHelper.Fireworks;
            this.bestSelector = new BestSelector(this.getBest, this.samplingNumber);
        }

        [Fact]
        public void Select_Missing2ndParam_ReturnsEqualFireworks()
        {
            IEnumerable<Firework> expectedFireworks = SelectorTestsHelper.BestFireworks;

            IEnumerable<Firework> resultingFireworks = bestSelector.Select(this.allFireworks);

            Assert.NotSame(expectedFireworks, resultingFireworks);
            Assert.Equal(expectedFireworks, resultingFireworks);
        }

        [Fact]
        public void Select_Missing2ndParam_ReturnsNonEqualFireworks()
        {
            IEnumerable<Firework> expectedFireworks = SelectorTestsHelper.NonBestFireworks;

            IEnumerable<Firework> resultingFireworks = bestSelector.Select(this.allFireworks);

            Assert.NotSame(expectedFireworks, resultingFireworks);
            Assert.NotEqual(expectedFireworks, resultingFireworks);
        }

        [Fact]
        public void Select_PresentAllParam_ReturnsEqualFireworks()
        {
            IEnumerable<Firework> expectedFireworks = SelectorTestsHelper.BestFireworks;

            IEnumerable<Firework> resultingFireworks = bestSelector.Select(this.allFireworks, this.samplingNumber);

            Assert.NotSame(expectedFireworks, resultingFireworks);
            Assert.Equal(expectedFireworks, resultingFireworks);
        }

        [Fact]
        public void Select_PresentAllParam_ReturnsNonEqualFireworks()
        {
            IEnumerable<Firework> expectedFireworks = SelectorTestsHelper.NonBestFireworks;

            IEnumerable<Firework> resultingFireworks = bestSelector.Select(this.allFireworks, this.samplingNumber);

            Assert.NotSame(expectedFireworks, resultingFireworks);
            Assert.NotEqual(expectedFireworks, resultingFireworks);
        }

        [Fact]
        public void Select_NullAs1stParam_ExceptionThrown()
        {
            IEnumerable<Firework> currentFireworks = null;
            string expectedParamName = "from";

            ArgumentNullException actualException = Assert.Throws<ArgumentNullException>(() => this.bestSelector.Select(currentFireworks));

            Assert.NotNull(actualException);
            Assert.Equal(expectedParamName, actualException.ParamName);
        }

        [Fact]
        public void Select_NegativeNumberAs2ndParam_ExceptionThrown()
        {
            string expectedParamName = "numberToSelect";

            ArgumentOutOfRangeException actualException = Assert.Throws<ArgumentOutOfRangeException>(() => this.bestSelector.Select(this.allFireworks, -1));

            Assert.NotNull(actualException);
            Assert.Equal(expectedParamName, actualException.ParamName);
        }

        [Fact]
        public void Select_GreatNumberAs2ndParam_ExceptionThrown()
        {
            string expectedParamName = "numberToSelect";
            int samplingNumber = this.countFireworks + 1;

            ArgumentOutOfRangeException actualException = Assert.Throws<ArgumentOutOfRangeException>(() => this.bestSelector.Select(this.allFireworks, samplingNumber));

            Assert.NotNull(actualException);
            Assert.Equal(expectedParamName, actualException.ParamName);
        }

        [Fact]
        public void Select_CountFireworksEqual2ndParam_ReturnsEqualFireworks()
        {
            IEnumerable<Firework> expectedFireworks = this.allFireworks;
            int samplingNumber = this.countFireworks;

            IEnumerable<Firework> resultingFireworks = bestSelector.Select(this.allFireworks, samplingNumber);

            Assert.NotSame(expectedFireworks, resultingFireworks);
            Assert.Equal(expectedFireworks, resultingFireworks);
        }

        [Fact]
        public void Select_NullAs2ndParam_ReturnsEmptyCollectionFireworks()
        {
            IEnumerable<Firework> expectedFireworks = new List<Firework>();

            IEnumerable<Firework> resultingFireworks = bestSelector.Select(this.allFireworks, 0);

            Assert.NotSame(expectedFireworks, resultingFireworks);
            Assert.Equal(expectedFireworks, resultingFireworks);
        }
    }
}
{'fraction_non_alphanumeric': 0.07403066705732982, 'fraction_numerical': 0.001953315753491552, 'mean_word_length': 2.9613152804642167, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 49, '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': '6956116', 'n_tokens_mistral': 2521, 'n_tokens_neox': 2440, 'n_words': 416}