public async Task should_throw_mismatch_id_exception_when_id_and_external_id_do_not_match() { var notification = await TestDataManager.SeedSendingNotification(); _notifications.Add(notification); var command = new UpdateNotificationDeliveryStatusCommand(notification.Id, "1234", DeliveryStatus.Delivered); Assert.ThrowsAsync <NotificationIdMismatchException>(() => _handler.Handle(command)); }
public async Task Should_Update_Delivery_Status_To_Created() { var notification = await TestDataManager.SeedSendingNotification(); _notifications.Add(notification); const DeliveryStatus expectedDeliveryStatus = DeliveryStatus.Created; var command = new UpdateNotificationSentCommand(notification.Id, notification.ExternalId, notification.Payload); await _handler.Handle(command); await using var db = new NotificationsApiDbContext(NotifyBookingsDbContextOptions); var updatedNotification = await db.Notifications.SingleOrDefaultAsync(x => x.Id == notification.Id); updatedNotification.Should().NotBeNull(); updatedNotification.DeliveryStatus.Should().Be(expectedDeliveryStatus); }
public async Task should_update_delivery_status_for_notification() { // Arrange var notification = await TestDataManager.SeedSendingNotification(); _notifications.Add(notification); const DeliveryStatus deliveryStatus = DeliveryStatus.Delivered; var command = new UpdateNotificationDeliveryStatusCommand(notification.Id, notification.ExternalId, deliveryStatus); // Act await _handler.Handle(command); // Assert await using var db = new NotificationsApiDbContext(NotifyBookingsDbContextOptions); var updatedNotification = await db.Notifications.SingleOrDefaultAsync(x => x.Id == notification.Id); updatedNotification.Should().NotBeNull(); updatedNotification.DeliveryStatus.Should().Be(deliveryStatus); }
public async Task Should_Assign_ExternalId_And_Payload() { var notification = await TestDataManager.SeedSendingNotification(); _notifications.Add(notification); const string expectedExternalId = "1234"; const string expectedPayload = "payload"; notification.AssignExternalId(expectedExternalId); notification.AssignPayload(expectedPayload); var command = new UpdateNotificationSentCommand(notification.Id, notification.ExternalId, notification.Payload); await _handler.Handle(command); await using var db = new NotificationsApiDbContext(NotifyBookingsDbContextOptions); var updatedNotification = await db.Notifications.SingleOrDefaultAsync(x => x.Id == notification.Id); updatedNotification.Payload.Should().Be(expectedPayload); updatedNotification.ExternalId.Should().Be(expectedExternalId); }