public void raise_sessionCanceled_when_cancel() { var context = TestSession.Create(); var session = context.Builder.Create(); session.Cancel("because !"); session.UncommitedEvents.GetStream().Should().Contain(new SessionCanceled(Guid.Empty, 0, "because !")); }
public void not_be_updated_on_a_weekend_day() { var context = TestSession.Create(); var session = context.Builder.Create(); Action action = () => session.Update(context.TrainingId, new DateTime(2018, 1, 4), 5, 5, context.LocationId, context.TrainerId); action.ShouldThrow <SessionWeekEndException>(); }
public void raise_sessionDeleted_when_delete_session() { var context = TestSession.Create(); var session = context.Builder.Create(); session.Delete(); session.UncommitedEvents.GetStream().Should().Contain(new SessionDeleted(Guid.NewGuid(), 1)); }
public void not_raise_sessionCanceled_if_session_deleted() { var context = TestSession.Create(); context.Builder.AddEvent(new SessionDeleted(Guid.Empty, 2)); var session = context.Builder.Create(); session.Cancel("OK"); session.UncommitedEvents.GetStream().Should().BeEmpty(); }
public void not_raise_sessionUpdated_if_session_alrady_updated_with_same_data() { var context = TestSession.Create(); context.Builder.AddEvent(new SessionUpdated(Guid.Empty, 0, new DateTime(2018, 1, 1), 4, 3, context.LocationId, context.TrainerId, context.TrainingId)); var session = context.Builder.Create(); session.Update(context.TrainingId, new DateTime(2018, 1, 1), 4, 3, context.LocationId, context.TrainerId); session.UncommitedEvents.GetStream().Should().BeEmpty(); }
public void not_raise_sessionDeleted_when_session_already_deleted() { var context = TestSession.Create(); context.Builder.AddEvent(new SessionDeleted(Guid.NewGuid(), 1)); var session = context.Builder.Create(); session.Delete(); session.UncommitedEvents.GetStream().Should().BeEmpty(); }
public void raise_seatReserved_if_seat_available() { var context = TestSession.Create(); var session = context.Builder.Create(); var studentId = Guid.NewGuid(); var companyId = Guid.NewGuid(); var seat = session.BookSeat(studentId, companyId); session.UncommitedEvents.GetStream().Should().Contain(new SessionSeatBooked(Guid.Empty, 0, studentId)); seat.UncommitedEvents.GetStream().Should() .Contain(new SeatCreated(Guid.Empty, 1, session.AggregateId, studentId, companyId)); }
public void throw_error_if_traying_to_set_certificateOfAttendence_to_non_assigned_student() { var context = TestSession.Create(); var studentId = Guid.NewGuid(); var documentId = Guid.NewGuid(); context.Builder.AddEvent(new SessionSeatBooked(Guid.Empty, 5, studentId)); var session = context.Builder.Create(); Action action = () => session.SendCertificateOfAttendance(Guid.NewGuid(), documentId); action.ShouldThrow <StudentNotInSessionException>(); }
public void send_certificateOfAttendenceSent() { var context = TestSession.Create(); var studentId = Guid.NewGuid(); var documentId = Guid.NewGuid(); context.Builder.AddEvent(new SessionSeatBooked(Guid.Empty, 5, studentId)); var session = context.Builder.Create(); session.SendCertificateOfAttendance(studentId, documentId); session.UncommitedEvents.GetStream().Should().Contain(new CertificateOfAttendanceSent(Guid.Empty, 1, studentId, documentId)); }
public void throw_error_if_update_nbrSeats_lower_than_seats_already_reserved() { var context = TestSession.Create(); var session = context.Builder.Create(); session.BookSeat(Guid.NewGuid(), Guid.NewGuid()); session.BookSeat(Guid.NewGuid(), Guid.NewGuid()); session.BookSeat(Guid.NewGuid(), Guid.NewGuid()); session.BookSeat(Guid.NewGuid(), Guid.NewGuid()); Action action = () => session.Update(context.TrainingId, DateTime.Now, 0, 3, context.LocationId, context.TrainerId); action.ShouldThrow <TooManySeatsAlreadyReservedException>(); }
public void throw_exception_if_trying_to_reserve_a_seat_when_no_seats_are_available() { var context = TestSession.Create(); var session = context.Builder.Create(); session.BookSeat(Guid.NewGuid(), Guid.NewGuid()); session.BookSeat(Guid.NewGuid(), Guid.NewGuid()); session.BookSeat(Guid.NewGuid(), Guid.NewGuid()); session.BookSeat(Guid.NewGuid(), Guid.NewGuid()); session.BookSeat(Guid.NewGuid(), Guid.NewGuid()); Action action = () => session.BookSeat(Guid.NewGuid(), Guid.NewGuid()); action.ShouldThrow <NoMoreSeatAvailableException>(); }