public void reasign_old_period_if_properly_removed() { var history = new History(); history.Add(new TrainerCreated(Guid.NewGuid(), 1, "BOUDOUX", "Aurelien", "*****@*****.**")); var trainer = new Trainer(history); trainer.Assign(new DateTime(2017, 01, 15), 10); trainer.UnAssign(new DateTime(2017, 01, 15), 10); trainer.Assign(new DateTime(2017, 01, 13), 10); }
public Session Execute(Guid trainingId, DateTime start, int duration, int nbrSeats, Guid?locationId, Guid?trainerId) { Trainer trainer = null; if (trainerId.HasValue) { trainer = GetAggregate <Trainer>(trainerId.Value); if (trainer == null) { throw new TrainerNotExistsException(); } trainer.Assign(start, duration); } Location location = null; if (locationId.HasValue) { location = GetAggregate <Location>(locationId.Value); if (location == null) { throw new LocationNotExistsException(); } location.Assign(start, duration); } var session = Session.Plan(trainingId, start, duration, nbrSeats, locationId, trainerId); var notification = NotificationManager.Create(session.AggregateId); PublishUncommitedEvents(trainer, location, session, notification); return(session); }
public void raise_TrainerAssigned_when_trainer_is_assigned_to_a_session() { var history = new History(); history.Add(new TrainerCreated(Guid.NewGuid(), 1, "BOUDOUX", "Aurelien", "*****@*****.**")); var trainer = new Trainer(history); trainer.Assign(new DateTime(2017, 12, 20), 3); trainer.UncommitedEvents.GetStream().Should().Contain(new TrainerAssigned(Guid.Empty, 0, new DateTime(2017, 12, 20), 3)); }
public void throw_error_if_formateur_already_assigned_to_a_session(string startDate, int duration) { var history = new History(); history.Add(new TrainerCreated(Guid.NewGuid(), 1, "BOUDOUX", "Aurelien", "*****@*****.**")); history.Add(new TrainerAssigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10)); var trainer = new Trainer(history); var start = DateTime.ParseExact(startDate, "dd/MM/yyyy", new DateTimeFormatInfo()); Action action = () => trainer.Assign(start, duration); action.ShouldThrow <TrainerAlreadyAssignedException>(); }
public void reasign_old_period_if_properly_removed_from_event_store() { var history = new History(); history.Add(new TrainerCreated(Guid.NewGuid(), 1, "BOUDOUX", "Aurelien", "*****@*****.**")); history.Add(new TrainerAssigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10)); history.Add(new TrainerUnassigned(Guid.NewGuid(), 2, new DateTime(2017, 01, 15), 10)); var trainer = new Trainer(history); trainer.Assign(new DateTime(2017, 01, 13), 10); trainer.UncommitedEvents.GetStream().Should().Contain(new TrainerAssigned(Guid.Empty, 1, new DateTime(2017, 01, 13), 10)); }