public void DummyToString() { var s = new DummyNotification { EventId = 123 }.ToString(); Assert.AreEqual("Notification: 123", s); }
public async Task Can_produce_outbox_message() { var spy = new KafkaProducerSpy(); var services = new ServiceCollection(); var fake = new FakeOutboxPersistence(); var dummyNotification = new DummyNotification(); var messageId = Guid.NewGuid().ToString(); services.AddLogging(); services.AddOutbox(options => { options.WithMessageIdGenerator(new MessageIdGeneratorStub(() => messageId)); options.Register <DummyMessage>("foo", "bar", x => "baz"); options.WithOutboxMessageRepository(serviceProvider => fake); options.WithNotifier(serviceProvider => dummyNotification); }); services.AddOutboxProducer(options => { options.WithBootstrapServers("localhost"); options.WithKafkaProducerFactory(() => spy); options.WithUnitOfWorkFactory(serviceProvider => fake); options.WithNotification(serviceProvider => dummyNotification); }); var provider = services.BuildServiceProvider(); var outbox = provider.GetRequiredService <OutboxQueue>(); await outbox.Enqueue(new[] { new DummyMessage() }); var pollingPublisher = provider .GetServices <IHostedService>() .OfType <OutboxDispatcherHostedService>() .First(); using (var cts = new CancellationTokenSource()) { cts.CancelAfter(10); pollingPublisher.ProcessOutbox(cts.Token); } Assert.True(fake.OutboxMessages.All(x => x.ProcessedUtc.HasValue)); Assert.True(fake.Committed); Assert.Equal("foo", spy.LastMessage.Topic); Assert.Equal(messageId, spy.LastMessage.MessageId); Assert.Equal("bar", spy.LastMessage.Type); Assert.Equal("baz", spy.LastMessage.Key); // Assert.Equal("", spy.LastOutgoingMessage.Value); }
static async Task RunAsync(object e) { PlayerDetail playerDetail = new PlayerDetail(); JournalItem journalItem = new JournalItem(); DummyNotification notificationItem = new DummyNotification(); try { using (var context = new DummyEntities()) { if (e is PlayerDetail) { playerDetail = (PlayerDetail)e; journalItem = null; notificationItem = null; } else if (e is JournalItem) { journalItem = (JournalItem)e; playerDetail = null; notificationItem = null; } else if (e is DummyNotification) { notificationItem = (DummyNotification)e; playerDetail = null; journalItem = null; } // TODO: Add UserEventNotification changes here as well. On insert we will call the CheckforOTWNotifications under D:\Qasir Data\Dummy\DummyAPI\Dummy.NotificationServices\Helpers\DummyNotificationProcessor.cs // TODO: Add MatchStateNotification changes here as well. On insert we will call the CheckforMatchStateNotifications under D:\Qasir Data\Dummy\DummyAPI\Dummy.NotificationServices\Helpers\DummyNotificationProcessor.cs List <PlayerJournalDTO> PlayerJournalDTOList = new List <PlayerJournalDTO>(); PlayerJournalDTOList.Add(new PlayerJournalDTO() { PlayerDetail = playerDetail, JournalItem = journalItem, DummyNotification = notificationItem }); var url = await PostsAsync(PlayerJournalDTOList); Console.WriteLine($"Created at {url}"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }