Пример #1
0
        public void DispatchEventWhenABindExists()
        {
            DomainEvent.Bind <TestEvent, FirstTestHandler>(serviceProviderMock.Object);

            DomainEvent.Dispatch(new TestEvent());

            Assert.True(FirstTestHandler.WasCalled);
        }
Пример #2
0
        internal void EnableAnswersOfTheCurrentQuestion(Guid userId)
        {
            if (UserIsTheFacilitator(userId))
            {
                CurrentQuestion.EnableAnswers();

                DomainEvent.Dispatch(new WhenTheQuestionIsEnabled(this));
            }
        }
Пример #3
0
        public void BindMoreThanOneHandlerToTheSameEvent()
        {
            DomainEvent.Bind <TestEvent, FirstTestHandler>(serviceProviderMock.Object);
            DomainEvent.Bind <TestEvent, SecondTestHandler>(serviceProviderMock.Object);

            DomainEvent.Dispatch(new TestEvent());

            Assert.True(FirstTestHandler.WasCalled);
            Assert.True(SecondTestHandler.WasCalled);
        }
Пример #4
0
        internal void AnswerTheCurrentQuestion(Guid userId, Answer answer, string annotation)
        {
            if (UserCanAnswerTheCurrentQuestion(userId))
            {
                CurrentQuestion.ContabilizeTheAnswer(userId, answer, annotation);

                if (CurrentQuestion.AllUsersHasAnswered(Participants))
                {
                    CurrentQuestion.DisableAnswers();

                    ChangeTheCurrentQuestion();

                    DomainEvent.Dispatch(new WhenAllUsersAnswerTheQuestion(this));
                }
            }
        }
Пример #5
0
        public void NotDispatchEventWhenABindNotExists()
        {
            DomainEvent.Dispatch(new TestEvent());

            Assert.False(ThirdTestHandler.WasCalled);
        }