<commit_before>using System.Collections.Generic;
using System.IO;
using System.Linq;
using Agdur.Abstractions;
using Agdur.Tests.Utilities;
using Xunit;

namespace Agdur.Tests
{
    public class BenchmarkTests
    {
        [Fact]
        public void Should_be_able_to_set_custom_benchmark_strategy_provider()
        {
            bool wasCalled = false;
            Benchmark.SetBenchmarkStrategyProvider(action =>
            {
                wasCalled = true;
                return new DefaultBenchmarkStrategy(action);
            });

            Benchmark.This(() => new object());

            wasCalled.ShouldBeTrue();
        }

        public class BenchmarkProfile : IBenchmarkProfile
        {
            public IBenchmarkBuilderContinutation Define(IBenchmarkBuilder builder)
            {
                return builder.Times(10).Average().InMilliseconds();
            }
        }
    }

    public class Should_be_able_to_benchmark_with
    {
        private readonly IBenchmarkBuilderWithSyntax<IBenchmarkBuilderContinutation> builder =
            Benchmark.This(() => new object()).Times(1);

        [Fact]
        public void Custom_metric()
        {
            builder.WithCustom(new MultipleValueMetric("custom", data => data));
        }

        [Fact]
        public void Custom_simplified_single_metric()
        {
            builder.WithCustom("custom", data => data.Sum());
        }

        [Fact]
        public void Custom_simplified_multiple_metric()
        {
            builder.WithCustom("custom", data => data);
        }

        [Fact]
        public void Average()
        {
            builder.Average();
        }

        [Fact]
        public void First()
        {
            builder.First(1);
        }

        [Fact]
        public void Max()
        {
            builder.Max();
        }

        [Fact]
        public void Min()
        {
            builder.Min();
        }

        [Fact]
        public void Total()
        {
            builder.Total();
        }
    }

    public class Should_be_able_to_benchmark_with_multiple_times
    {
        private readonly IBenchmarkBuilderWithSyntax<IBenchmarkBuilderContinutation> builder =
            Benchmark.This(() => new object()).Times(1);

        [Fact]
        public void Multiple_custom_metrics()
        {
            builder
                .WithCustom("custom", data => data.Sum()).InTicks()
                .WithCustom("custom", data => data.Sum()).InTicks();
        }
    }

    public class Should_be_able_to_benchmark_in
    {
        private readonly IBenchmarkBuilderInSyntax<IBenchmarkBuilderContinutation> builder =
            Benchmark.This(() => new object()).Times(1).WithCustom(new MultipleValueMetric("custom", data => data));

        [Fact]
        public void Custom_time()
        {
            builder.InCustom(sample => sample.Seconds, "s");
        }

        [Fact]
        public void Milliseconds()
        {
            builder.InMilliseconds();
        }

        [Fact]
        public void Ticks()
        {
            builder.InTicks();
        }
    }

    public class Should_be_able_to_benchmark_once_in
    {
        private readonly IBenchmarkBuilderInSyntax<ISingleBenchmarkBuilderContinuation> builder =
            Benchmark.This(() => new object()).Once().Value();

        [Fact]
        public void Custom_time()
        {
            builder.InCustom(sample => sample.Seconds, "s");
        }

        [Fact]
        public void Milliseconds()
        {
            builder.InMilliseconds();
        }

        [Fact]
        public void Ticks()
        {
            builder.InTicks();
        }
    }

    public class Should_be_able_to_benchmark_to
    {
        private readonly IBenchmarkBuilderContinutation builder =
            Benchmark.This(() => new object()).Times(10).WithCustom(new SingleValueMetric("custom", data => data.Sum())).InCustom(sample => sample.Seconds, "s");

        [Fact]
        public void Custom()
        {
            builder.ToCustom(new StringWriter());
        }

        [Fact]
        public void Console()
        {
            builder.ToConsole();
        }

        [Fact]
        public void Path()
        {
            builder.ToPath("filename");
        }
    }

    public class Should_be_able_to_benchmark_as
    {
        private readonly IBenchmarkBuilderAsSyntax builder =
            Benchmark.This(() => new object()).Times(10).WithCustom(new SingleValueMetric("custom", data => data.Sum())).InCustom(sample => sample.Seconds, "s").ToConsole();

        [Fact]
        public void Custom()
        {
            builder.AsCustom(new CustomOutputStrategy());
        }

        [Fact]
        public void FormattedString()
        {
            builder.AsFormattedString();
        }

        [Fact]
        public void Xml()
        {
            builder.AsXml();
        }

        public class CustomOutputStrategy : IOutputStrategy
        {
            public void Execute(TextWriter writer, IList<IMetric> metrics) { }
        }
    }
}<commit_msg>Updated tests in the Agdur namespace using nunit.<commit_after>using System.Collections.Generic;
using System.IO;
using System.Linq;
using Agdur.Abstractions;
using NUnit.Framework;

namespace Agdur.Tests
{
    public class BenchmarkTests
    {
        [Test]
        public void Should_be_able_to_set_custom_benchmark_strategy_provider()
        {
            bool wasCalled = false;
            Benchmark.SetBenchmarkStrategyProvider(action =>
            {
                wasCalled = true;
                return new DefaultBenchmarkStrategy(action);
            });

            Benchmark.This(() => new object());

            Assert.That(wasCalled, Is.True);
        }

        public class BenchmarkProfile : IBenchmarkProfile
        {
            public IBenchmarkBuilderContinutation Define(IBenchmarkBuilder builder)
            {
                return builder.Times(10).Average().InMilliseconds();
            }
        }
    }

    // "Assert" that we don't break the fluent interface for multiple samples '.WithCustom()'.
    public class Should_be_able_to_benchmark_with
    {
        private readonly IBenchmarkBuilderWithSyntax<IBenchmarkBuilderContinutation> tbuilder = 
            Benchmark.This(() => new object()).Times(1);

        [Test]
        public void Custom_metric()
        {
            tbuilder.WithCustom(new MultipleValueMetric("custom", data => data));
        }

        [Test]
        public void Multiple_custom_metrics()
        {
            tbuilder
                .WithCustom("custom", data => data.Sum()).InTicks()
                .WithCustom("custom", data => data.Sum()).InTicks();
        }

        [Test]
        public void Custom_simplified_single_metric()
        {
            tbuilder.WithCustom("custom", data => data.Sum());
        }

        [Test]
        public void Custom_simplified_multiple_metric()
        {
            tbuilder.WithCustom("custom", data => data);
        }

        [Test]
        public void Average()
        {
            tbuilder.Average();
        }

        [Test]
        public void First()
        {
            tbuilder.First(1);
        }

        [Test]
        public void Max()
        {
            tbuilder.Max();
        }

        [Test]
        public void Min()
        {
            tbuilder.Min();
        }

        [Test]
        public void Total()
        {
            tbuilder.Total();
        }
    }

    // "Assert" that we don't break the fluent interface for '.InCustom()'.
    public class Should_be_able_to_benchmark_in
    {
        private readonly IBenchmarkBuilderInSyntax<IBenchmarkBuilderContinutation> tbuilder =
            Benchmark.This(() => new object()).Times(1).WithCustom(new MultipleValueMetric("custom", data => data));

        private readonly IBenchmarkBuilderInSyntax<ISingleBenchmarkBuilderContinuation> obuilder =
            Benchmark.This(() => new object()).Once().Value();

        [Test]
        public void Custom_time()
        {
            tbuilder.InCustom(sample => sample.Seconds, "s");
            obuilder.InCustom(sample => sample.Seconds, "s");
        }

        [Test]
        public void Milliseconds()
        {
            tbuilder.InMilliseconds();
            obuilder.InMilliseconds();
        }

        [Test]
        public void Ticks()
        {
            tbuilder.InTicks();
            obuilder.InTicks();
        }
    }

    // "Assert" that we don't break the fluent interface for '.ToCustom()'.
    public class Should_be_able_to_benchmark_to
    {
        private readonly IBenchmarkBuilderContinutation tbuilder =
            Benchmark.This(() => new object()).Times(1).WithCustom(new SingleValueMetric("custom", data => data.Sum())).InCustom(sample => sample.Seconds, "s");

        private readonly ISingleBenchmarkBuilderContinuation obuilder =
            Benchmark.This(() => new object()).Once().Value().InCustom(sample => sample.Seconds, "s");

        [Test]
        public void Custom()
        {
            tbuilder.ToCustom(new StringWriter());
            obuilder.ToCustom(new StringWriter());
        }

        [Test]
        public void Console()
        {
            tbuilder.ToConsole();
            obuilder.ToConsole();
        }

        [Test]
        public void Path()
        {
            tbuilder.ToPath("filename");
            obuilder.ToPath("filename");
        }
    }

    // "Assert" that we don't break the fluent interface for '.AsCustom()'.
    public class Should_be_able_to_benchmark_as
    {
        private readonly IBenchmarkBuilderAsSyntax tbuilder =
            Benchmark.This(() => new object()).Times(10).WithCustom(new SingleValueMetric("custom", data => data.Sum())).InCustom(sample => sample.Seconds, "s").ToCustom(new StringWriter());

        private readonly IBenchmarkBuilderAsSyntax obuilder =
            Benchmark.This(() => new object()).Once().Value().InCustom(sample => sample.Seconds, "s").ToCustom(new StringWriter());

        [Test]
        public void Custom()
        {
            tbuilder.AsCustom(new CustomOutputStrategy());
            obuilder.AsCustom(new CustomOutputStrategy());
        }

        [Test]
        public void FormattedString()
        {
            tbuilder.AsFormattedString();
            obuilder.AsFormattedString();
        }

        [Test]
        public void Xml()
        {
            tbuilder.AsXml();
            obuilder.AsXml();
        }

        public class CustomOutputStrategy : IOutputStrategy
        {
            public void Execute(TextWriter writer, IList<IMetric> metrics) { }
        }
    }
}
{'fraction_non_alphanumeric': 0.10644677661169415, 'fraction_numerical': 0.001686656671664168, 'mean_word_length': 1.8227982015339856, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 55, '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': '2866801', 'n_tokens_mistral': 2892, 'n_tokens_neox': 2779, 'n_words': 553}