public async Task It_Returns_A_Failure_If_Course_Not_Found() { var student = new Student( new StudentName("Jordan Walker"), new EmailAddress("*****@*****.**") ); await studentRepositorySpy.Add(student); var command = new DisenrollStudentCommand(student.Id, Guid.NewGuid(), "Comment."); var result = await handler.Handle(command, new CancellationToken()); Assert.True(result.IsFailure); Assert.IsType <CourseNotFoundError>(result.Error); }
public async Task It_Returns_A_Failure_If_From_Course_Not_Found() { var student = new Student( new StudentName("Jordan Walker"), new EmailAddress("*****@*****.**") ); var toCourse = new Course( new CourseTitle("Philsophy"), new Credits(1) ); await studentRepositorySpy.Add(student); await courseRepositorySpy.Add(toCourse); var command = new TransferStudentCommand(student.Id, Guid.NewGuid(), toCourse.Id, "A"); var result = await handler.Handle(command, new CancellationToken()); Assert.True(result.IsFailure); Assert.IsType <CourseNotFoundError>(result.Error); }
public async Task It_Returns_A_Failed_Result_If_Student_Already_Exists() { var student = new Student( new StudentName("Jordan Walker"), new EmailAddress("*****@*****.**") ); await studentRepositorySpy.Add(student); var command = new RegisterStudentCommand("Jordan Walker", "*****@*****.**"); var result = await handler.Handle(command, new CancellationToken()); Assert.True(result.IsFailure); Assert.IsType <StudentAlreadyRegisteredError>(result.Error); }
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); }
public async Task It_Updates_The_Student() { var student = new Student( new StudentName("Jordan Walker"), new EmailAddress("*****@*****.**") ); await studentRepositorySpy.Add(student); var command = new EditStudentDetailsCommand(student.Id, "Walker Jordan", "*****@*****.**"); var result = await handler.Handle(command, new CancellationToken()); Assert.True(result.IsSuccess); Assert.Equal("Walker Jordan", student.Name.Name); Assert.Equal("*****@*****.**", student.Email.Address); Assert.True(unitOfWorkSpy.WasCommited); }