public async Task Handle_NoExistingPacienteIdCommandUpsertEdit_ShouldThrowNotFoundException() { // Arrange var mediatorMock = new Mock <IMediator>(); var sut = new UpsertPacienteCommand.UpsertPacienteCommandHandler(_context, mediatorMock.Object); var noExistingPacienteId = 1003; _command.Id = noExistingPacienteId; // Act // Assert await Assert.ThrowsAsync <NotFoundException>(() => sut.Handle(_command, CancellationToken.None)); }
public void Handle_ValidCommandUpsertCreate_ShouldRaiseNotifaction() { // Arrange var mediatorMock = new Mock <IMediator>(); var sut = new UpsertPacienteCommand.UpsertPacienteCommandHandler(_context, mediatorMock.Object); var nextPacienteId = 1003; _command.Id = null; // Act var result = sut.Handle(_command, CancellationToken.None); // Assert mediatorMock.Verify(m => m.Publish(It.Is <UpsertPacienteNotification>(pc => pc.PacienteId == nextPacienteId), It.IsAny <CancellationToken>()), Times.Once); }