public async Task Handle_NullArgument_ThrowsException() { // Arrange var repository = new Mock <IDataAvailableNotificationRepository>(); var target = new InsertDataAvailableNotificationsCommandHandler(repository.Object); // Act + Assert await Assert .ThrowsAsync <ArgumentNullException>(() => target.Handle(null !, CancellationToken.None)) .ConfigureAwait(false); }
public async Task Handle_WithNotifications_DataIsSaved() { // Arrangem var repository = new Mock <IDataAvailableNotificationRepository>(); var target = new InsertDataAvailableNotificationsCommandHandler(repository.Object); const string recipient = "7495563456235"; const string origin = "TimeSeries"; var dataAvailableNotifications = new[] { new DataAvailableNotificationDto( "E8E875C0-250D-4B82-9357-4CE26E0E7A1E", recipient, "fake_value_1", origin, true, 1, 1, "RSM??"), new DataAvailableNotificationDto( "70469BE2-EFA3-4CBA-ABAF-AAE573BF057E", recipient, "fake_value_2", origin, true, 2, 2, "RSM??"), new DataAvailableNotificationDto( "F8FC4D49-5245-4924-80D3-F1FB81FA3903", recipient, "fake_value_3", origin, false, 3, 3, "RSM??"), }; var request = new InsertDataAvailableNotificationsCommand(dataAvailableNotifications); // Act await target.Handle(request, CancellationToken.None).ConfigureAwait(false); // Assert repository.Verify( x => x.SaveAsync( It.Is(ExpectedCabinetKey(dataAvailableNotifications[0])), It.Is(ExpectedNotification(dataAvailableNotifications[0]))), Times.Once); repository.Verify( x => x.SaveAsync( It.Is(ExpectedCabinetKey(dataAvailableNotifications[1])), It.Is(ExpectedNotification(dataAvailableNotifications[1]))), Times.Once); repository.Verify( x => x.SaveAsync( It.Is(ExpectedCabinetKey(dataAvailableNotifications[2])), It.Is(ExpectedNotification(dataAvailableNotifications[2]))), Times.Once); }