예제 #1
0
 protected override void AddPlayers(EventPlayer player)
 {
     player.Add <SessionDeleted>(e => _isDeleted = true)
     .Add <SessionUpdated>(e =>
     {
         _lastUpdate     = e;
         TrainerId       = e.TrainerId;
         LocationId      = e.LocationId;
         SessionStart    = e.SessionStart;
         Duration        = e.Duration;
         _availableSeats = e.Seats;
     })
     .Add <SessionCanceled>(e => _isCanceled = true)
     .Add <SessionPlanned>(e =>
     {
         _availableSeats = e.Seats;
         TrainerId       = e.TrainerId;
         LocationId      = e.LocationId;
         SessionStart    = e.SessionStart;
         Duration        = e.Duration;
     })
     .Add <SessionSeatBooked>(e =>
     {
         _bookedSeats++;
         if (e.StudentId.HasValue)
         {
             _bookedStudent.Add(e.StudentId.Value);
         }
     })
     .Add <SessionSeatReleased>(e =>
     {
         _bookedSeats--;
         _bookedStudent.Remove(e.StudentId);
     });
 }
예제 #2
0
 protected override void AddPlayers(EventPlayer player)
 {
     base.AddPlayers(player);
     player.Add <TrainerAssigned>(e => _assignedSession.Add(e.SessionStart, e.Duration))
     .Add <TrainerReassigned>(e => _assignedSession.Update(e.OldSessionStart, e.OldDuration, e.NewSessionStart, e.NewDuration))
     .Add <TrainerUnassigned>(e => _assignedSession.Remove(e.SessionStart, e.Duration))
     .Add <TrainerDisabled>(e => _isDisabled = true);
 }
예제 #3
0
 protected override void AddPlayers(EventPlayer player)
 {
     base.AddPlayers(player);
     player.Add <LocationAssigned>(e => _assignedSession.Add(e.SessionStart, e.Duration))
     .Add <LocationReassigned>(e => _assignedSession.Update(e.OldSessionStart, e.OldDuration, e.NewSessionStart, e.NewDuration))
     .Add <LocationUnassigned>(e => _assignedSession.Remove(e.SessionStart, e.Duration))
     .Add <LocationDisabled>(a => _disabled = true);
 }
        public void dont_raise_event_for_unregistered_event()
        {
            var raised1 = false;

            var player = new EventPlayer();

            player.Add <TestEvent1>(a => { raised1 = true; });

            player.Apply(new TestEvent2());
            raised1.Should().BeFalse();
        }
        public void apply_method_for_one_event()
        {
            var raised = false;

            var player = new EventPlayer();

            player.Add <TestEvent1>(a => { raised = true; });
            player.Apply(new TestEvent1());

            raised.Should().BeTrue();
        }
예제 #6
0
 protected override void AddPlayers(EventPlayer player)
 {
     player.Add <NotificationManagerCreated>(a => _sessionId = a.SessionId)
     .Add <SeatToValidateNotificationSent>(a => _notifications.Add(a))
     .Add <AgreementToCreateNotificationSent>(a => _notifications.Add(a))
     .Add <AgreementToSignNotificationSent>(a => _notifications.Add(a))
     .Add <NotificationRemoved>(a => _notifications.RemoveAll(b => b.NotificationId == a.NotificationId))
     .Add <CreateSeatSignaled>(a => _seatStates.Add(new SeatState(a.SeatId, a.CompanyId)))
     .Add <ValidateSeatSignaled>(a => UpdateSeatState(a.SeatId, SeatStatus.Valid))
     .Add <RefuseSeatSignaled>(a => UpdateSeatState(a.SeatId, SeatStatus.Refused))
     .Add <CancelSeatSignaled>(a => UpdateSeatState(a.SeatId, SeatStatus.Canceled))
     .Add <AgreementAssociatedToSeatSignaled>(a => UpdateSeatAgreement(a.SeatId, a.AgreementId))
     .Add <SeatToDefineStudentNotificationSent>(a => _notifications.Add(a))
     ;
 }
        public void deal_with_event_member_when_applying()
        {
            var expectedResult = string.Empty;

            var player = new EventPlayer();

            player.Add <TestEvent1>(a => { expectedResult = a.Test; });

            var ev = new TestEvent1()
            {
                Test = "ESSAI"
            };

            player.Apply(ev);

            expectedResult.Should().Be("ESSAI");
        }
        public void apply_method_for_two_events()
        {
            var raised1 = false;
            var raised2 = false;

            var player = new EventPlayer();

            player.Add <TestEvent1>(a => { raised1 = true; })
            .Add <TestEvent2>(a => raised2 = true);

            player.Apply(new TestEvent1());
            raised1.Should().BeTrue();
            raised2.Should().BeFalse();

            player.Apply(new TestEvent2());
            raised2.Should().BeTrue();
        }
예제 #9
0
 protected override void AddPlayers(EventPlayer player)
 {
     if (player == null)
     {
         throw new ArgumentNullException(nameof(player));
     }
     player
     .Add <SeatCanceled>(e => _currentSeatStatus = SeatStatus.Canceled)
     .Add <SeatValided>(e => _currentSeatStatus  = SeatStatus.Valid)
     .Add <SeatRefused>(e => _currentSeatStatus  = SeatStatus.Refused)
     .Add <SeatCreated>(e =>
     {
         SessionId = e.SessionId;
         CompanyId = e.CompanyId;
         StudentId = e.StudentId;
     })
     .Add <AgreementAssociated>(e => AssociatedAgreementId    = e.AgreementId)
     .Add <AgreementDisassociated>(e => AssociatedAgreementId = null)
     .Add <MissingStudentReported>(e => _missingStudent       = true)
     .Add <SeatStudentUpdated>(e => StudentId = e.NewStudentId);
 }
예제 #10
0
 protected override void AddPlayers(EventPlayer player)
 {
     base.AddPlayers(player);
     player.Add <TrainingDisabled>(e => _disabled = true);
 }
예제 #11
0
 protected override void AddPlayers(EventPlayer player)
 {
     base.AddPlayers(player);
     player.Add <UserCreated>(e => _currentRole = e.Role);
 }
예제 #12
0
 protected override void AddPlayers(EventPlayer player)
 {
     player.Add <AgreementRevoked>(e => _isRevoked = true);
 }