public void ProgressEvaluationToFollowup()
        {
            Project     project     = _projectService.Create("ProgressEvaluationToFollowup");
            Evaluation  evaluation  = _evaluationService.Create("ProgressEvaluationToFollowup", project);
            Participant participant = _participantService.Create("ProgressEvaluationToFollowup", evaluation, Organization.All, Role.Facilitator);

            List <Question> questions = _questionService.CreateBulk(_questionTemplateService.GetAll().ToList(), evaluation);

            _answerService.Create(participant, questions[0], Severity.High, "test_answer_0", Progression.Workshop);
            _answerService.Create(participant, questions[1], Severity.High, "test_answer_1", Progression.Workshop);
            _answerService.Create(participant, questions[2], Severity.High, "test_answer_2", Progression.Workshop);

            int nAnswersWorkshop = _context.Answers.Where(
                a => (a.Progression.Equals(Progression.Workshop) && a.Question.Evaluation.Equals(evaluation))
                ).Count();

            // Forces null on db relations
            // To simulate behavior of normal API call
            _context.ChangeTracker.Clear();

            _mutation.ProgressEvaluation(evaluation.Id, Progression.FollowUp);

            int nAnswersFollowup = _context.Answers.Where(
                a => (a.Progression.Equals(Progression.FollowUp) && a.Question.Evaluation.Equals(evaluation))
                ).Count();

            Assert.Equal(nAnswersWorkshop, nAnswersFollowup);
        }
Exemple #2
0
        public void CreateFollowUpAnswers()
        {
            ParticipantService participantService = new ParticipantService(fixture.context);
            QuestionService    questionService    = new QuestionService(fixture.context);
            AnswerService      answerService      = new AnswerService(fixture.context);

            ProjectService    projectService    = new ProjectService(fixture.context);
            Project           project           = projectService.Create("AnswerService_GetFromQuestionExists");
            EvaluationService evaluationService = new EvaluationService(fixture.context);
            Evaluation        evaluation        = evaluationService.Create("AnswerService_GetFromQuestionExists", project, "");

            Participant             participant = participantService.Create("CreateFollowUpAnswers_id", evaluation, Organization.All, Role.Facilitator);
            QuestionTemplateService qts         = new QuestionTemplateService(fixture.context);
            List <Question>         questions   = questionService.CreateBulk(qts.GetAll().ToList(), evaluation);

            answerService.Create(participant, questions[0], Severity.High, "test_answer_0", Progression.Workshop);
            answerService.Create(participant, questions[1], Severity.High, "test_answer_1", Progression.Workshop);
            answerService.Create(participant, questions[2], Severity.High, "test_answer_2", Progression.Workshop);

            int nAnswersFollowupBefore = answerService.GetAll().Where(a => (a.Progression.Equals(Progression.FollowUp) && a.Question.Evaluation.Equals(evaluation))).Count();
            int nAnswersWorkshop       = answerService.GetAll().Where(a => (a.Progression.Equals(Progression.Workshop) && a.Question.Evaluation.Equals(evaluation))).Count();

            answerService.CreateFollowUpAnswers(evaluation);
            int nAnswersFollowup = answerService.GetAll().Where(a => (a.Progression.Equals(Progression.FollowUp) && a.Question.Evaluation.Equals(evaluation))).Count();

            Assert.Equal(nAnswersFollowupBefore + nAnswersWorkshop, nAnswersFollowup);
        }
Exemple #3
0
        /* Primary mutations - manupulating specific Evaluations */
        public Evaluation CreateEvaluation(
            string name,
            string projectId,
            string previousEvaluationId,
            string projectCategoryId
            )
        {
            var azureUniqueId = _authService.GetOID();

            var project    = _projectService.GetProject(projectId);
            var evaluation = _evaluationService.Create(
                name: name,
                project: project,
                previousEvaluationId: previousEvaluationId
                );

            _participantService.Create(
                azureUniqueId: azureUniqueId,
                evaluation: evaluation,
                organization: Organization.All,
                role: Role.Facilitator
                );

            var projectCategory = _projectCategoryService.Get(projectCategoryId);
            var questions       = _questionTemplateService.ActiveQuestions(projectCategory);

            _questionService.CreateBulk(questions, evaluation);
            _questionService.SquashOrder(evaluation.Questions);

            var log = $"Evaluation with id: {evaluation.Id} was created by azureId: {azureUniqueId}";

            _logger.LogInformation(log);
            return(evaluation);
        }
        public void SetWorkshopCompleteDate()
        {
            Project           project    = GetProject();
            EvaluationService service    = new EvaluationService(fixture.context);
            Evaluation        evaluation = service.Create("eval_name", project, "");

            System.DateTimeOffset testStartDate = System.DateTimeOffset.UtcNow;

            Assert.Null(evaluation.WorkshopCompleteDate);

            evaluation.Progression = Progression.Workshop;
            var exceptionProgress = Assert.Throws <System.InvalidOperationException>
                                        (() => service.SetWorkshopCompleteDate(evaluation));

            Assert.Contains(
                $"WorkshopCompleteDate requires an evaluation on FollowUp; it is: {evaluation.Progression}",
                exceptionProgress.Message);

            evaluation.Progression = Progression.FollowUp;
            service.SetWorkshopCompleteDate(evaluation);
            Assert.True(testStartDate < evaluation.WorkshopCompleteDate);

            var exceptionPreviouslySet = Assert.Throws <System.InvalidOperationException>
                                             (() => service.SetWorkshopCompleteDate(evaluation));

            Assert.Contains(
                $"Completion date already set as: {evaluation.WorkshopCompleteDate}",
                exceptionPreviouslySet.Message);
        }
        public void SetStatus()
        {
            Project           project    = GetProject();
            EvaluationService service    = new EvaluationService(fixture.context);
            Evaluation        evaluation = service.Create("eval_name", project, "");

            Status newStatus = Status.Voided;

            service.SetStatus(evaluation, newStatus);
            Assert.Equal(newStatus, evaluation.Status);
        }
        public void GetExists()
        {
            Project project = GetProject();

            EvaluationService evaluationService = new EvaluationService(fixture.context);
            Evaluation        evaluationCreate  = evaluationService.Create("some__name", project, "");

            Evaluation evaluationGet = evaluationService.GetEvaluation(evaluationCreate.Id);

            Assert.Equal(evaluationCreate, evaluationGet);
        }
Exemple #7
0
        public Evaluation CreateEvaluation(string name, string projectId)
        {
            string     azureUniqueId = _authService.GetOID();
            Project    project       = _projectService.GetProject(projectId);
            Evaluation evaluation    = _evaluationService.Create(name, project);

            _participantService.Create(azureUniqueId, evaluation, Organization.All, Role.Facilitator);

            _questionService.CreateBulk(_questionTemplateService.ActiveQuestions(), evaluation);
            return(evaluation);
        }
        public void SetSummary()
        {
            Project           project    = GetProject();
            EvaluationService service    = new EvaluationService(fixture.context);
            Evaluation        evaluation = service.Create("eval_name", project, "");

            string summary = "Summary";

            Assert.Equal("", evaluation.Summary);
            service.SetSummary(evaluation, summary);
            Assert.Equal(summary, evaluation.Summary);
        }
        public void GetExists()
        {
            ProjectService projectService = new ProjectService(_context);
            Project        project        = projectService.GetAll().First();

            EvaluationService evaluationService = new EvaluationService(_context);
            Evaluation        evaluationCreate  = evaluationService.Create("some_evaluation_name", project);

            Evaluation evaluationGet = evaluationService.GetEvaluation(evaluationCreate.Id);

            Assert.Equal(evaluationCreate, evaluationGet);
        }
        public void Create()
        {
            Project           project           = GetProject();
            EvaluationService evaluationService = new EvaluationService(fixture.context);

            int nEvaluationsBefore = evaluationService.GetAll().Count();

            evaluationService.Create("some_name", project, "");
            int nEvaluationsAfter = evaluationService.GetAll().Count();

            Assert.Equal(nEvaluationsBefore + 1, nEvaluationsAfter);
        }
        public void Create()
        {
            ProjectService projectService = new ProjectService(_context);
            Project        project        = projectService.GetAll().First();

            EvaluationService evaluationService = new EvaluationService(_context);

            int nEvaluationsBefore = evaluationService.GetAll().Count();

            evaluationService.Create("some_name", project);
            int nEvaluationsAfter = evaluationService.GetAll().Count();

            Assert.Equal(nEvaluationsBefore + 1, nEvaluationsAfter);
        }
        public void ProgressEvaluation()
        {
            Project project = GetProject();

            EvaluationService evaluationService = new EvaluationService(fixture.context);
            Evaluation        evaluation        = evaluationService.Create("some_name", project, "");
            Progression       nextEvaluation    = ServiceUtil.NextProgression(evaluation.Progression);

            Progression progressionBefore = evaluation.Progression;

            evaluationService.ProgressEvaluation(evaluation, nextEvaluation);
            Progression progressionAfter = evaluation.Progression;

            Assert.True(ServiceUtil.NextProgression(progressionBefore).Equals(progressionAfter));
        }
Exemple #13
0
        public void ProgressEvaluation()
        {
            ProjectService projectService = new ProjectService(_context);
            Project        project        = projectService.GetAll().First();

            EvaluationService evaluationService = new EvaluationService(_context);
            Evaluation        evaluation        = evaluationService.Create("some_name", project);

            Progression progressionBefore = evaluation.Progression;

            evaluationService.ProgressEvaluation(evaluation.Id);
            Progression progressionAfter = evaluation.Progression;

            Assert.True(ServiceUtil.NextProgression(progressionBefore).Equals(progressionAfter));
        }
Exemple #14
0
        public void ProgressParticipant()
        {
            ProjectService     projectService     = new ProjectService(_context);
            ParticipantService participantService = new ParticipantService(_context);
            EvaluationService  evaluationService  = new EvaluationService(_context);
            Project            project            = projectService.Create("ProgressParticipant");
            Evaluation         evaluation         = evaluationService.Create("ProgressParticipant", project);
            Participant        participant        = participantService.Create("ProgressParticipant", evaluation, Organization.All, Role.Facilitator);

            Progression progressionBefore = participant.Progression;

            participantService.ProgressParticipant(participant, Progression.Individual);
            Progression progressionAfter = participant.Progression;

            Assert.Equal(Progression.Nomination, progressionBefore);
            Assert.Equal(Progression.Individual, progressionAfter);
        }
        public void GetExists()
        {
            QuestionTemplateService questionTemplateService = new QuestionTemplateService(_context);
            QuestionTemplate        questionTemplate        = questionTemplateService.GetAll().First();

            ProjectService    projectService    = new ProjectService(_context);
            Project           project           = projectService.Create("QuestionService_GetExists");
            EvaluationService evaluationService = new EvaluationService(_context);
            Evaluation        evaluation        = evaluationService.Create("QuestionService_GetExists", project);

            QuestionService questionService = new QuestionService(_context);
            Question        questionCreate  = questionService.Create(questionTemplate, evaluation);

            Question questionGet = questionService.GetQuestion(questionCreate.Id).First();

            Assert.Equal(questionCreate, questionGet);
        }
        public void Create()
        {
            QuestionTemplateService questionTemplateService = new QuestionTemplateService(_context);
            QuestionTemplate        questionTemplate        = questionTemplateService.GetAll().First();

            ProjectService    projectService    = new ProjectService(_context);
            Project           project           = projectService.Create("QuestionService_Create");
            EvaluationService evaluationService = new EvaluationService(_context);
            Evaluation        evaluation        = evaluationService.Create("QuestionService_Create", project);

            QuestionService questionService = new QuestionService(_context);

            int nQuestionBefore = questionService.GetAll().Count();

            questionService.Create(questionTemplate, evaluation);
            int nQuestionsAfter = questionService.GetAll().Count();

            Assert.Equal(nQuestionBefore + 1, nQuestionsAfter);
        }
        public void CreateBulk()
        {
            QuestionTemplateService questionTemplateService = new QuestionTemplateService(_context);
            List <QuestionTemplate> questionTemplates       = questionTemplateService.GetAll().ToList();

            ProjectService    projectService    = new ProjectService(_context);
            Project           project           = projectService.Create("QuestionService_CreateBulk");
            EvaluationService evaluationService = new EvaluationService(_context);
            Evaluation        evaluation        = evaluationService.Create("QuestionService_CreateBulk", project);

            QuestionService questionService = new QuestionService(_context);

            int nQuestionBefore = questionService.GetAll().Count();

            questionService.CreateBulk(questionTemplates, evaluation);
            int nQuestionsAfter = questionService.GetAll().Count();

            Assert.Equal(nQuestionBefore + 15, nQuestionsAfter);
        }
Exemple #18
0
        public void ProgressAllParticipants()
        {
            ProjectService     projectService     = new ProjectService(_context);
            ParticipantService participantService = new ParticipantService(_context);
            EvaluationService  evaluationService  = new EvaluationService(_context);
            Project            project            = projectService.Create("ProgressAllParticipants");
            Evaluation         evaluation         = evaluationService.Create("ProgressAllParticipants", project);
            Participant        participant1       = participantService.Create("ProgressAllParticipants1", evaluation, Organization.All, Role.Facilitator);
            Participant        participant2       = participantService.Create("ProgressAllParticipants2", evaluation, Organization.Commissioning, Role.OrganizationLead);

            Progression progression1Before = participant1.Progression;

            participantService.ProgressAllParticipants(evaluation, Progression.Individual);
            Progression progression1After = participant1.Progression;
            Progression progression2After = participant2.Progression;

            Assert.Equal(Progression.Nomination, progression1Before);
            Assert.Equal(Progression.Individual, progression1After);
            Assert.Equal(Progression.Individual, progression2After);
        }
Exemple #19
0
        public void GetFromQuestionExists()
        {
            QuestionTemplateService questionTemplateService = new QuestionTemplateService(fixture.context);
            QuestionTemplate        questionTemplate        = questionTemplateService.GetAll().First();

            ProjectService    projectService    = new ProjectService(fixture.context);
            Project           project           = projectService.Create("AnswerService_GetFromQuestionExists");
            EvaluationService evaluationService = new EvaluationService(fixture.context);
            Evaluation        evaluation        = evaluationService.Create("AnswerService_GetFromQuestionExists", project, "");

            ParticipantService participantService = new ParticipantService(fixture.context);
            Participant        participant        = participantService.GetAll().ToList()[0];

            QuestionService questionService = new QuestionService(fixture.context);
            Question        question        = questionService.Create(questionTemplate, evaluation);

            AnswerService answerService = new AnswerService(fixture.context);
            Answer        answerCreate  = answerService.Create(participant, question, Severity.High, "test_answer", participant.Progression);

            Answer answerGet = answerService.GetAnswer(question, participant, question.Evaluation.Progression);

            Assert.Equal(answerCreate, answerGet);
        }