public async Task UpdateHandle_NullArgument_ThrowsException()
        {
            // Arrange
            var repository = new Mock <ISequenceNumberRepository>();
            var target     = new MaximumSequenceNumberCommandHandler(repository.Object);
            var updateMaximumSequenceNumberCommand = (UpdateMaximumSequenceNumberCommand)null !;

            // Act + Assert
            await Assert
            .ThrowsAsync <ArgumentNullException>(() => target.Handle(updateMaximumSequenceNumberCommand, CancellationToken.None))
            .ConfigureAwait(false);
        }
        public async Task UpdateHandle_SequenceNumber_IsSaved()
        {
            // Arrange
            const long sequenceNumber = 100;

            var repository = new Mock <ISequenceNumberRepository>();
            var target     = new MaximumSequenceNumberCommandHandler(repository.Object);

            // Act
            var command = new UpdateMaximumSequenceNumberCommand(sequenceNumber);
            await target.Handle(command, CancellationToken.None).ConfigureAwait(false);

            // Assert
            repository.Verify(x => x.AdvanceSequenceNumberAsync(It.Is <SequenceNumber>(s => s.Value == sequenceNumber)));
        }
        public async Task GetHandle_SequenceNumber_IsReturned()
        {
            // Arrange
            const long expected = 170989;

            var repository = new Mock <ISequenceNumberRepository>();

            repository.Setup(x => x.GetMaximumSequenceNumberAsync())
            .ReturnsAsync(new SequenceNumber(expected));

            var target = new MaximumSequenceNumberCommandHandler(repository.Object);

            // Act
            var command = new GetMaximumSequenceNumberCommand();
            var actual  = await target.Handle(command, CancellationToken.None).ConfigureAwait(false);

            // Assert
            Assert.Equal(expected, actual);
        }