public async Task CantRemoveMessageWithoutSavingAsync()
        {
            // Arrange
            var ctx = _ctx;
            var msg = new OutboxMessage
            {
                Body        = "test",
                MessageType = Abstractions.Models.OutboxMessageType.ProcessingDataMessage,
                OccurredOn  = DateTime.UtcNow
            };

            ctx.OutboxMessages.Add(msg);
            ctx.SaveChanges();
            var logger = new Mock <ILogger <OutboxUnitOfWork> >();
            var outbox = new OutboxUnitOfWork(ctx, logger.Object);

            // Act
            var exception = await Record.ExceptionAsync(async() =>
            {
                await outbox.RemoveOutboxMessageAsync(new TestMessage
                {
                    MessageId = msg.MessageId
                }, CancellationToken.None);
            });

            // Assert
            exception.Should().BeNull();
            ctx.OutboxMessages.Should().NotBeEmpty();
        }
        public async Task CantWorkWithDisposedObjectAsync2()
        {
            // Arrange
            var ctx    = _ctx;
            var logger = new Mock <ILogger <OutboxUnitOfWork> >();
            var outbox = new OutboxUnitOfWork(ctx, logger.Object);
            await outbox.DisposeAsync();

            // Act
            var exception = await Record.ExceptionAsync(async() => await outbox.RemoveOutboxMessageAsync(new TestMessage(), CancellationToken.None));

            // Assert
            exception.Should().NotBeNull().And.BeOfType <ObjectDisposedException>();
        }
        public async Task CanRemoveMessageAsync()
        {
            // Arrange
            var ctx  = _ctx;
            var msg1 = new OutboxMessage
            {
                Body        = "test1",
                MessageType = Abstractions.Models.OutboxMessageType.ProcessingDataMessage,
                OccurredOn  = DateTime.UtcNow
            };
            var msg2 = new OutboxMessage
            {
                Body        = "test2",
                MessageType = Abstractions.Models.OutboxMessageType.ProcessingDataMessage,
                OccurredOn  = DateTime.UtcNow.AddDays(1)
            };

            ctx.OutboxMessages.Add(msg1);
            ctx.OutboxMessages.Add(msg2);
            ctx.SaveChanges();
            var logger = new Mock <ILogger <OutboxUnitOfWork> >();
            var outbox = new OutboxUnitOfWork(ctx, logger.Object);

            // Act
            var exception = await Record.ExceptionAsync(async() =>
            {
                await outbox.RemoveOutboxMessageAsync(new TestMessage
                {
                    MessageId = msg1.MessageId
                }, CancellationToken.None);
                await outbox.SaveAsync(CancellationToken.None);
            });

            // Assert
            exception.Should().BeNull();
            ctx.OutboxMessages.Should().HaveCount(1);
            ctx.OutboxMessages.Single().Should().Be(msg2);
        }