public void Handle_GivenInvalidId_ThrowsException() { var command = new UpdateEmailCommand { Id = 99, Description = "Test Update Description", Subject = "Test Update Subject", Body = "Test Update Body" }; var handler = new UpdateEmailCommand.UpdateEmailCommandHandler(Context); Should.ThrowAsync <NotFoundException>(() => handler.Handle(command, CancellationToken.None)); }
public async Task Handle_GivenValidId_ShouldUpdatePersistedEmail() { var command = new UpdateEmailCommand { Id = 1, Description = "Test Update Description", Subject = "Test Update Subject", Body = "Test Update Body" }; var handler = new UpdateEmailCommand.UpdateEmailCommandHandler(Context); await handler.Handle(command, CancellationToken.None); var entity = Context.Emails.Find(command.Id); entity.ShouldNotBeNull(); entity.Description.ShouldBe(command.Description); entity.Subject.ShouldBe(command.Subject); entity.Body.ShouldBe(command.Body); }