コード例 #1
0
        public IActionResult UnregisterStudent(int id)
        {
            var command = new UnregisterStudentCommand(id);
            var result  = _messages.Dispatch(command);

            return(HandleCommandResult(result));
        }
コード例 #2
0
        public async Task It_Returns_An_Error_If_Student_Not_Found()
        {
            var command = new UnregisterStudentCommand(Guid.NewGuid());
            var result  = await handler.Handle(command, new CancellationToken());

            Assert.True(result.IsFailure);
        }
        public async Task <IActionResult> Unregister([FromRoute] Guid id)
        {
            var command = new UnregisterStudentCommand(id);
            var result  = await mediator.Send(command);

            return(FromPresenter(new UnregisterStudentPresenter(result)));
        }
コード例 #4
0
        public async Task It_Unregisters_The_Student()
        {
            var student = new Student(
                new StudentName("Jordan Walker"),
                new EmailAddress("*****@*****.**")
                );
            await studentRepositorySpy.Add(student);

            var command = new UnregisterStudentCommand(student.Id);
            var result  = await handler.Handle(command, new CancellationToken());

            Assert.True(result.IsSuccess);
            Assert.Empty(studentRepositorySpy.Students);
            Assert.True(unitOfWorkSpy.WasCommited);
        }