public async Task Should_clear_dispatched_messages_and_cleanup_queue_after_given_expiry() { configuration.RequiresOutboxSupport(); var storage = (OutboxStorage)configuration.OutboxStorage; var ctx = configuration.GetContextBagForOutbox(); var messageId = Guid.NewGuid().ToString(); var messageToStore = new OutboxMessage(messageId, new[] { new TransportOperation("x", null, null, null) }); using (var transaction = await storage.BeginTransaction(ctx)) { await storage.Store(messageToStore, transaction, ctx); await transaction.Commit(); } // Account for the low resolution of DateTime.UtcNow. var afterStore = DateTimeOffset.UtcNow.AddTicks(1); await storage.SetAsDispatched(messageId, configuration.GetContextBagForOutbox()); await configuration.CleanupMessagesOlderThan(afterStore); var message = await storage.Get(messageId, configuration.GetContextBagForOutbox()); using (var tx = stateManager.CreateTransaction()) { Assert.AreEqual(0, await storage.Cleanup.GetCountAsync(tx)); Assert.AreEqual(0, await storage.Outbox.GetCountAsync(tx)); } Assert.Null(message); }
public async Task Should_clear_operations_on_dispatched_messages() { configuration.RequiresOutboxSupport(); var storage = configuration.OutboxStorage; var ctx = configuration.GetContextBagForOutbox(); var messageId = Guid.NewGuid().ToString(); var messageToStore = new OutboxMessage(messageId, new[] { new TransportOperation("x", null, null, null) }); using (var transaction = await storage.BeginTransaction(ctx)) { await storage.Store(messageToStore, transaction, ctx); await transaction.Commit(); } await storage.SetAsDispatched(messageId, configuration.GetContextBagForOutbox()); var message = await storage.Get(messageId, configuration.GetContextBagForOutbox()); Assert.False(message.TransportOperations.Any()); }