Ejemplo n.º 1
0
        public void SurveyResponse_AddResponse_ValidResponse_ShouldAddOnList()
        {
            var survey = SurveyResponse.Create(Guid.NewGuid(), 1000);

            var response = QuestionResponse.Create(DataHelper.GetKeyValuePairs(),
                                                   DataHelper.GetKeyValuePairs(),
                                                   new[] { DataHelper.GetKeyValuePairs() },
                                                   string.Empty,
                                                   2);

            Action addResponse = () => survey.AddResponse(response);

            addResponse.Should().NotThrow();
            survey.Responses.Should().HaveCount(1);
        }
Ejemplo n.º 2
0
        public void SurveyResponse_AddResponse_RepeatedResponse_ShouldThrowDomainException()
        {
            var survey = SurveyResponse.Create(Guid.NewGuid(), 1000);

            var response = QuestionResponse.Create(DataHelper.GetKeyValuePairs(),
                                                   DataHelper.GetKeyValuePairs(),
                                                   new[] { DataHelper.GetKeyValuePairs() },
                                                   string.Empty,
                                                   2);

            survey.AddResponse(response);
            Action addResponse = () => survey.AddResponse(response);

            addResponse.Should().Throw <DomainException>();
            survey.Responses.Should().HaveCount(1);
        }
Ejemplo n.º 3
0
        public async Task <bool> Handle(QuestionAnsweredEvent request, CancellationToken cancellationToken)
        {
            SurveyResponse surveyResponse = await _surveyResponseUnitOfWork.GetOrCreate(
                new { request.QuestionnareId, request.ExecutionId },
                () => SurveyResponse.Create(request.ExecutionId, request.QuestionnareId));

            QuestionResponse response = QuestionResponse.Create(request.Subject,
                                                                request.Question,
                                                                request.Answers,
                                                                request.Answer,
                                                                request.AnswerIndex);

            surveyResponse.AddResponse(response);

            await _surveyResponseUnitOfWork.Commit();

            return(true);
        }
Ejemplo n.º 4
0
        public async Task QuestionAnsweredEventHandlerTest_Handle_ValidInput()
        {
            var executionId = Guid.NewGuid();
            var eventHander = new QuestionAnsweredEventHandler(_unitOfWork);
            var survey      = SurveyResponse.Create(executionId, 1000);
            var @event      = new QuestionAnsweredEvent
            {
                Answer         = string.Empty,
                AnswerIndex    = 2,
                Answers        = new[] { DataHelper.GetKeyValuePairs() },
                ExecutionId    = executionId,
                Question       = DataHelper.GetKeyValuePairs(),
                QuestionnareId = 1000,
                Subject        = DataHelper.GetKeyValuePairs()
            };

            _unitOfWork.SetEntity(survey);

            var handleResult = await eventHander.Handle(@event, default);

            handleResult.Should().BeTrue();
        }
Ejemplo n.º 5
0
        public void SurveyResponse_IsValid_ValidResponse_ShouldBeTrue()
        {
            var survey = SurveyResponse.Create(Guid.NewGuid(), 1000);

            survey.IsValid().Should().BeTrue();
        }