Example #1
0
        public async void RemoveExamWithQuestions_WhenExamExists_DeleteExamsAndQuestions()
        {
            using (var fixture = new ExamsFixture())
            {
                await fixture.Repository.AddAsync(new ExamBuilder("Some-exam", ExamType.Specialization, "Some-category")
                                                  .WithQuestion("Q1", CorrectAnswer.B)
                                                  .WithQuestion("Q2", CorrectAnswer.D)
                                                  .Build()
                                                  );

                var allExams = fixture.GetAllExams();
                var examsCountBeforeDelete = allExams.Count;

                var command = new DeleteExamCommand();
                var handler = new DeleteExamCommandHandler(fixture.Repository, allExams.First().Id);
                await handler.HandleAsync(command);

                var result = await fixture.Repository.GetByIdAsync(allExams.First().Id);

                examsCountBeforeDelete.Should().Be(1);
                result.Should().BeNull();
                fixture.GetAllExams().Count.Should().Be(0);
            }
        }
 public Task <IActionResult> Delete(long examId)
 {
     return(NoContentOrUnprocessableEntityOrNotFound(DeleteExamCommand.Create(examId, _examExistenceValidator),
                                                     DomainErrors.AggregateNotFound));
 }
 public async Task <IActionResult> Delete(Guid id, [FromRoute] DeleteExamCommand command)
 => await DispatchCommandAsync(command, id);