public void not_remove_agreement_to_sign_when_removing_valided_seat_where_agreement_not_created()
        {
            var context = TestSessionNotification.Create();
            var notif   = context.Builder.Create();

            context.AddSeat();
            context.AddSeat(context.Seat(0).CompanyId);

            notif.SignalSeatCreated(context.Seat(0).SeatId, context.Seat(0).CompanyId, Guid.NewGuid(), false);
            notif.SignalSeatCreated(context.Seat(1).SeatId, context.Seat(1).CompanyId, Guid.NewGuid(), false);

            notif.SignalSeatValidated(context.Seat(0).SeatId, context.Seat(0).CompanyId);
            notif.SignalSeatValidated(context.Seat(1).SeatId, context.Seat(1).CompanyId);

            var agreementId = Guid.NewGuid();

            notif.SignalAgreementAssociated(agreementId, context.Seat(0).SeatId, context.Seat(0).CompanyId);
            notif.SignalAgreementAssociated(agreementId, context.Seat(1).SeatId, context.Seat(1).CompanyId);

            context.AddSeat(context.Seat(0).CompanyId);
            notif.SignalSeatCreated(context.Seat(2).SeatId, context.Seat(2).CompanyId, Guid.NewGuid(), false);
            notif.SignalSeatValidated(context.Seat(2).SeatId, context.Seat(2).CompanyId);
            notif.SignalSeatRefused(context.Seat(2).SeatId, context.Seat(2).CompanyId);

            var hanlder = new FakeNotificationHanlder(notif.UncommitedEvents);

            hanlder.Notifications.Should().HaveCount(1).And.Contain(a => a.Type == NotificationType.AgreementToSign);
        }
        public void raise_remove_AgreementToSignNotificationSent_when_signal_agreement_signed_for_secon_agreement()
        {
            var context = TestSessionNotification.Create();
            var notif   = context.Builder.Create();

            context.AddSeat();
            context.AddSeat(context.Seat(0).CompanyId);

            notif.SignalSeatCreated(context.Seat(0).SeatId, context.Seat(0).CompanyId, Guid.NewGuid());
            notif.SignalSeatCreated(context.Seat(1).SeatId, context.Seat(1).CompanyId, Guid.NewGuid());

            notif.SignalSeatValidated(context.Seat(0).SeatId, context.Seat(0).CompanyId);
            notif.SignalSeatValidated(context.Seat(1).SeatId, context.Seat(1).CompanyId);

            var agreementId1 = Guid.NewGuid();
            var agreementId2 = Guid.NewGuid();

            notif.SignalAgreementAssociated(agreementId1, context.Seat(0).SeatId, context.Seat(0).CompanyId);
            notif.SignalAgreementAssociated(agreementId2, context.Seat(1).SeatId, context.Seat(1).CompanyId);

            notif.SignalAgreementSigned(agreementId1);
            var hanlder = new FakeNotificationHanlder(notif.UncommitedEvents);

            hanlder.Notifications.Should().HaveCount(1)
            .And.Contain(a => a.Type == NotificationType.AgreementToSign && a.AgreementId == agreementId2);
        }
        public void re_raise_agreementToCreated_if_created_agreement_is_revoked()
        {
            var context = TestSessionNotification.Create();
            var notif   = context.Builder.Create();

            context.AddSeat();
            context.AddSeat(context.Seat(0).CompanyId);

            notif.SignalSeatCreated(context.Seat(0).SeatId, context.Seat(0).CompanyId, Guid.NewGuid());
            notif.SignalSeatCreated(context.Seat(1).SeatId, context.Seat(1).CompanyId, Guid.NewGuid());

            notif.SignalSeatValidated(context.Seat(0).SeatId, context.Seat(0).CompanyId);
            notif.SignalSeatValidated(context.Seat(1).SeatId, context.Seat(1).CompanyId);

            var agreementId = Guid.NewGuid();

            notif.SignalAgreementAssociated(agreementId, context.Seat(0).SeatId, context.Seat(0).CompanyId);
            notif.SignalAgreementAssociated(agreementId, context.Seat(1).SeatId, context.Seat(1).CompanyId);

            notif.SignalSeatCanceled(context.Seat(0).SeatId, context.Seat(0).CompanyId);
            notif.SignalAgreementRevoked(agreementId);

            var handler = new FakeNotificationHanlder(notif.UncommitedEvents);

            handler.Notifications.Should().HaveCount(1)
            .And.Contain(a => a.Type == NotificationType.AgreementToCreate);
        }
        public void remove_SeatToValidate_when_cancel_seat()
        {
            var context = TestSessionNotification.Create();
            var notif   = context.Builder.Create();

            context.AddSeat();
            notif.SignalSeatCreated(context.Seat(0).SeatId, context.Seat(0).CompanyId, Guid.NewGuid());
            notif.SignalSeatCanceled(context.Seat(0).SeatId, context.Seat(0).CompanyId);

            var handler = new FakeNotificationHanlder(notif.UncommitedEvents);

            handler.Notifications.Should().BeEmpty();
        }
        public void raise_agreement_to_create_notification_when_signal_seat_valided()
        {
            var context = TestSessionNotification.Create();
            var notif   = context.Builder.Create();

            context.AddSeat();
            notif.SignalSeatCreated(context.Seat(0).SeatId, context.Seat(0).CompanyId, Guid.NewGuid());
            notif.SignalSeatValidated(context.Seat(0).SeatId, context.Seat(0).CompanyId);

            var handler = new FakeNotificationHanlder(notif.UncommitedEvents);

            handler.Notifications.Should().HaveCount(1).And.Contain(a => a.Type == NotificationType.AgreementToCreate);
        }
        public void raise_SeatToDefineStudentNotificationSent_when_signal_seat_created_with_empty_student()
        {
            var context = TestSessionNotification.Create();
            var notif   = context.Builder.Create();

            context.AddSeat();

            notif.SignalSeatCreated(context.Seat(0).SeatId, context.Seat(0).CompanyId, null);

            var handler = new FakeNotificationHanlder(notif.UncommitedEvents);

            handler.Notifications.Should().HaveCount(1)
            .And.Contain(a => a.Type == NotificationType.StudentToDefine);
        }
        public void remove_student_to_define_notification_when_defined()
        {
            var context = TestSessionNotification.Create();
            var notif   = context.Builder.Create();

            context.AddSeat();

            notif.SignalSeatCreated(context.Seat(0).SeatId, context.Seat(0).CompanyId, null);
            notif.SignalSeatRedefined(context.Seat(0).SeatId, context.Seat(0).CompanyId, Guid.NewGuid());

            var handler = new FakeNotificationHanlder(notif.UncommitedEvents);

            handler.Notifications.Should().HaveCount(0);
        }
        public void resend_define_student_notification_if_redefine_to_null()
        {
            var context = TestSessionNotification.Create();
            var notif   = context.Builder.Create();

            context.AddSeat();

            notif.SignalSeatCreated(context.Seat(0).SeatId, context.Seat(0).CompanyId, Guid.NewGuid());
            notif.SignalSeatRedefined(context.Seat(0).SeatId, context.Seat(0).CompanyId, null);

            var handler = new FakeNotificationHanlder(notif.UncommitedEvents);

            handler.Notifications.Should().HaveCount(1)
            .And.Contain(a => a.Type == NotificationType.StudentToDefine);
        }
        public void raise_remove_AgreementToSignNotificationSent_when_signal_agreement_signed()
        {
            var context = TestSessionNotification.Create();
            var notif   = context.Builder.Create();

            context.AddSeat();
            var agreementId = Guid.NewGuid();

            notif.SignalSeatCreated(context.Seat(0).SeatId, context.Seat(0).CompanyId, Guid.NewGuid());
            notif.SignalSeatValidated(context.Seat(0).SeatId, context.Seat(0).CompanyId);
            notif.SignalAgreementAssociated(agreementId, context.Seat(0).SeatId, context.Seat(0).CompanyId);
            notif.SignalAgreementSigned(agreementId);

            var handler = new FakeNotificationHanlder(notif.UncommitedEvents);

            handler.Notifications.Should().BeEmpty();
        }
        public void remove_agreementToCreated_if_all_place_refused_or_canceled()
        {
            var context = TestSessionNotification.Create();
            var notif   = context.Builder.Create();

            context.AddSeat();
            context.AddSeat(context.Seat(0).CompanyId);

            notif.SignalSeatCreated(context.Seat(0).SeatId, context.Seat(0).CompanyId, Guid.NewGuid());
            notif.SignalSeatCreated(context.Seat(1).SeatId, context.Seat(1).CompanyId, Guid.NewGuid());

            notif.SignalSeatValidated(context.Seat(0).SeatId, context.Seat(0).CompanyId);
            notif.SignalSeatValidated(context.Seat(1).SeatId, context.Seat(1).CompanyId);

            notif.SignalSeatCanceled(context.Seat(0).SeatId, context.Seat(0).CompanyId);
            notif.SignalSeatRefused(context.Seat(1).SeatId, context.Seat(1).CompanyId);

            var handler = new FakeNotificationHanlder(notif.UncommitedEvents);

            handler.Notifications.Should().BeEmpty();
        }
        public void dont_raise_AgreementToSignNotificationSent_twice_when_creating_agreement_for_two_seat()
        {
            var context = TestSessionNotification.Create();
            var notif   = context.Builder.Create();

            context.AddSeat();
            context.AddSeat(context.Seat(0).CompanyId);

            var agreementId = Guid.NewGuid();

            notif.SignalSeatCreated(context.Seat(0).SeatId, context.Seat(0).CompanyId, Guid.NewGuid());
            notif.SignalSeatCreated(context.Seat(1).SeatId, context.Seat(1).CompanyId, Guid.NewGuid());
            notif.SignalSeatValidated(context.Seat(0).SeatId, context.Seat(0).CompanyId);
            notif.SignalSeatValidated(context.Seat(1).SeatId, context.Seat(1).CompanyId);
            notif.SignalAgreementAssociated(agreementId, context.Seat(0).SeatId, context.Seat(0).CompanyId);
            notif.SignalAgreementAssociated(agreementId, context.Seat(1).SeatId, context.Seat(1).CompanyId);

            var handler = new FakeNotificationHanlder(notif.UncommitedEvents);

            handler.Notifications.Should().HaveCount(1).And.Contain(a => a.Type == NotificationType.AgreementToSign);
        }
        public void dont_remove_agreementToCreated_if_one_place_already_valided()
        {
            var context = TestSessionNotification.Create();
            var notif   = context.Builder.Create();

            context.AddSeat();
            context.AddSeat(context.Seat(0).CompanyId);

            notif.SignalSeatCreated(context.Seat(0).SeatId, context.Seat(0).CompanyId, Guid.NewGuid());
            notif.SignalSeatCreated(context.Seat(1).SeatId, context.Seat(1).CompanyId, Guid.NewGuid());

            notif.SignalSeatValidated(context.Seat(0).SeatId, context.Seat(0).CompanyId);
            notif.SignalSeatValidated(context.Seat(1).SeatId, context.Seat(1).CompanyId);

            notif.SignalSeatCanceled(context.Seat(0).SeatId, context.Seat(0).CompanyId);

            var handler = new FakeNotificationHanlder(notif.UncommitedEvents);

            handler.Notifications.Should().HaveCount(1)
            .And.Contain(a => a.Type == NotificationType.AgreementToCreate)
            ;
        }