<commit_before>﻿using System.Threading;
using System.Threading.Tasks;
using Moq;
using NUnit.Framework;
using Projecto.Tests.TestClasses;

namespace Projecto.Tests
{
    [TestFixture]
    public class ProjectionTests
    {
        [Test]
        public void NextSequence_ValueAfterConstruction_ShouldStartAtFetchedValue()
        {
            Assert.That(new TestProjection(3).NextSequenceNumber, Is.EqualTo(3));
            Assert.That(new TestProjection().NextSequenceNumber, Is.EqualTo(1));
        }

        [Test]
        public void NextSequence_GetValueTwice_ShouldNotIncrement()
        {
            var projection = new TestProjection();
            Assert.That(projection.NextSequenceNumber, Is.EqualTo(1));
            Assert.That(projection.NextSequenceNumber, Is.EqualTo(1));
        }

        [Test]
        public async Task NextSequence_HandleMessage_ShouldIncrementNextSequence()
        {
            IProjection<FakeMessageEnvelope> projection = new TestProjection(5);
            Assert.That(projection.NextSequenceNumber, Is.EqualTo(5));
            await projection.Handle(() => new FakeConnection(), new FakeMessageEnvelope(5, new MessageA()), CancellationToken.None);
            Assert.That(projection.NextSequenceNumber, Is.EqualTo(6));
        }

        [Test]
        public void When_HandleMessages_ShouldCallCorrectHandlerWithCorrectArguments()
        {
            var connectionMock = new Mock<FakeConnection>();
            var token = new CancellationToken();
            var messageA = new MessageA();
            var messageB = new MessageB();
            var messageEnvelopeA = new FakeMessageEnvelope(1, messageA);
            var messageEnvelopeB = new FakeMessageEnvelope(2, messageB);

            IProjection<FakeMessageEnvelope> projection = new TestProjection();
            projection.Handle(() => connectionMock.Object, messageEnvelopeA, token);<commit_msg>Rename some projection test method names<commit_after>﻿using System.Threading;
using System.Threading.Tasks;
using Moq;
using NUnit.Framework;
using Projecto.Tests.TestClasses;

namespace Projecto.Tests
{
    [TestFixture]
    public class ProjectionTests
    {
        [Test]
        public void NextSequence_ValueAfterConstruction_ShouldStartAtFetchedValue()
        {
            Assert.That(new TestProjection(3).NextSequenceNumber, Is.EqualTo(3));
            Assert.That(new TestProjection().NextSequenceNumber, Is.EqualTo(1));
        }

        [Test]
        public void NextSequence_GetValueTwice_ShouldNotIncrement()
        {
            var projection = new TestProjection();
            Assert.That(projection.NextSequenceNumber, Is.EqualTo(1));
            Assert.That(projection.NextSequenceNumber, Is.EqualTo(1));
        }

        [Test]
        public async Task Handle_SomeMessage_ShouldIncrementNextSequence()
        {
            IProjection<FakeMessageEnvelope> projection = new TestProjection(5);
            Assert.That(projection.NextSequenceNumber, Is.EqualTo(5));
            await projection.Handle(() => new FakeConnection(), new FakeMessageEnvelope(5, new MessageA()), CancellationToken.None);
            Assert.That(projection.NextSequenceNumber, Is.EqualTo(6));
        }

        [Test]
        public void Handle_TwoDifferentMessages_ShouldCallCorrectHandlerWithCorrectArguments()
        {
            var connectionMock = new Mock<FakeConnection>();
            var token = new CancellationToken();
            var messageA = new MessageA();
            var messageB = new MessageB();
            var messageEnvelopeA = new FakeMessageEnvelope(1, messageA);
            var messageEnvelopeB = new FakeMessageEnvelope(2, messageB);

            IProjection<FakeMessageEnvelope> projection = new TestProjection();
            projection.Handle(() => connectionMock.Object, messageEnvelopeA, token);
{'fraction_non_alphanumeric': 0.0905071521456437, 'fraction_numerical': 0.005721716514954486, 'mean_word_length': 2.9244897959183676, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '3734098', 'n_tokens_mistral': 982, 'n_tokens_neox': 994, 'n_words': 200}