public void CourseEnrollmentCommand_Validate_InvalidCommand(bool generateValidGuid, string studentName, int studentAge) { var id = generateValidGuid ? Guid.NewGuid() : Guid.Empty; var command = new CourseEnrollmentCommand() { CourseId = id, StudentAge = studentAge, StudentName = studentName }; Action validation = () => command.Validate().Wait(); validation.Should().Throw <ValidationException>(); }
public async Task CourseEnrollmentCommandHandler_Handle_NewStudent() { // Arrange var courseId = Guid.NewGuid(); var handler = MockHelper.GetRequestHandler(courseId); var command = new CourseEnrollmentCommand() { CourseId = courseId, StudentAge = 16, StudentName = "Carl" }; // Act var result = await handler.Handle(command, default); // Assert result.Should().BeTrue(); }
public void CourseEnrollmentCommandHandler_Handle_InexistentCourse() { // Arrange var courseId = Guid.NewGuid(); var handler = MockHelper.GetRequestHandler(); var command = new CourseEnrollmentCommand() { CourseId = courseId, StudentAge = 24, StudentName = "William" }; // Act Action handle = () => handler.Handle(command, default).Wait(); // Assert handle.Should().Throw <ElementNotFoundException>(); }
public void CourseEnrollmentCommandHandler_Handle_CourseFull() { // Arrange var courseId = Guid.NewGuid(); var handler = MockHelper.GetRequestHandler(courseId, capacity: 1); var command = new CourseEnrollmentCommand() { CourseId = courseId, StudentAge = 24, StudentName = "William" }; // Act Action handle = () => handler.Handle(command, default).Wait(); // Assert handle.Should().Throw <CourseLimitException>(); }
public void CourseEnrollmentCommandHandler_Handle_DoubleApplication() { // Arrange var courseId = Guid.NewGuid(); var billId = Guid.NewGuid(); var handler = MockHelper.GetRequestHandler(courseId, billId); var command = new CourseEnrollmentCommand() { CourseId = courseId, StudentAge = 25, StudentName = "Bill" }; // Act Action handle = () => handler.Handle(command, default).Wait(); // Assert handle.Should().Throw <DoubleApplicationException>(); }