示例#1
0
        public void EditQuestionTemplate()
        {
            var     service    = new QuestionTemplateService(fixture.context);
            Barrier barrier    = Randomize.Barrier();
            var     originalQT = service.Create(
                barrier:      barrier,
                organization: Randomize.Organization(),
                text:         Randomize.String(),
                supportNotes: Randomize.String()
                );

            var projectCategory = new ProjectCategoryService(fixture.context).GetAll().First();

            originalQT = service.AddToProjectCategory(originalQT.Id, projectCategory.Id);

            var nTemplates = service.GetAll().Count();
            var nActive    = service.ActiveQuestions(projectCategory).Count();

            var newText         = Randomize.String();
            var newSupportNotes = Randomize.String();
            var newOrganization = Randomize.Organization();

            var updatedQT = service.Edit(
                questionTemplate: originalQT,
                barrier:          barrier,
                organization:     newOrganization,
                text:             newText,
                supportNotes:     newSupportNotes,
                status:           Status.Active
                );

            Assert.Equal(nTemplates + 1, service.GetAll().Count());
            Assert.Equal(nActive, service.ActiveQuestions(projectCategory).Count());

            Assert.Equal(newText, updatedQT.Text);
            Assert.Equal(newSupportNotes, updatedQT.SupportNotes);
            Assert.Equal(barrier, updatedQT.Barrier);
            Assert.Equal(newOrganization, updatedQT.Organization);

            Assert.Equal(originalQT, updatedQT.previous);
            Assert.True(updatedQT.ProjectCategories.Count() == 1);

            Assert.Equal(updatedQT.AdminOrder, originalQT.AdminOrder);
        }
示例#2
0
        protected Answer SetAnswer(
            string questionId,
            Severity?severity       = null,
            string text             = null,
            Progression?progression = null)
        {
            if (text == null)
            {
                text = Randomize.String();
            }

            Answer answer = _mutation.SetAnswer(
                questionId: questionId,
                severity: severity.GetValueOrDefault(Randomize.Severity()),
                text: text,
                progression: progression.GetValueOrDefault(Randomize.Progression())
                );

            return(answer);
        }
示例#3
0
        protected Participant CreateParticipant(
            Evaluation evaluation,
            string azureUniqueId      = null,
            Organization?organization = null,
            Role?role = null)
        {
            if (azureUniqueId == null)
            {
                azureUniqueId = Randomize.Integer().ToString();
            }

            Participant participant = _mutation.CreateParticipant(
                azureUniqueId: azureUniqueId,
                evaluationId: evaluation.Id,
                organization: organization.GetValueOrDefault(Randomize.Organization()),
                role: role.GetValueOrDefault(Randomize.Role())
                );

            return(participant);
        }
示例#4
0
        public void Delete()
        {
            var service            = new ProjectCategoryService(fixture.context);
            int nCategories        = service.GetAll().Count();
            var oldProjectCategory = service.GetAll().First();
            var newProjectCategory = service.CopyFrom(Randomize.String(), oldProjectCategory);

            var qtService        = new QuestionTemplateService(fixture.context);
            var questionTemplate = qtService
                                   .GetAll()
                                   .Include(x => x.ProjectCategories)
                                   .First(x => x.ProjectCategories.Contains(newProjectCategory))
            ;

            service.Delete(newProjectCategory);

            questionTemplate = qtService.GetQuestionTemplate(questionTemplate.Id);
            Assert.False(questionTemplate.ProjectCategories.Contains(newProjectCategory));

            Assert.Equal(nCategories, service.GetAll().Count());
        }
示例#5
0
        public void CreateAddsCorrectQuestions()
        {
            var projectCategory = _projectCategoryService
                                  .GetAll()
                                  .First()
            ;

            var nActiveTemplates = projectCategory.QuestionTemplates
                                   .Where(x => x.Status.Equals(Status.Active))
                                   .Count()
            ;

            var evaluation = _mutation.CreateEvaluation(
                name: Randomize.String(),
                projectId: _projectService.GetAll().First().Id,
                previousEvaluationId: "",
                projectCategoryId: projectCategory.Id
                );

            Assert.Equal(evaluation.Questions.Count(), nActiveTemplates);
        }
示例#6
0
        public void QuestionsHaveCorrectOrder()
        {
            var projectCategory = _projectCategoryService
                                  .GetAll()
                                  .Where(pc => pc.Name == "SquareField")
                                  .First()
            ;

            var evaluation = _mutation.CreateEvaluation(
                name: Randomize.String(),
                projectId: _projectService.GetAll().First().Id,
                previousEvaluationId: "",
                projectCategoryId: projectCategory.Id
                );

            var createdEvaluation = _evaluationService.GetEvaluation(evaluation.Id);
            int maxQuestionOrder  = createdEvaluation.Questions.Max(q => q.Order);
            var firstQuestion     = createdEvaluation.Questions.OrderBy(q => q.Order).First();

            Assert.Equal(1, firstQuestion.Order);
            Assert.Equal(createdEvaluation.Questions.Count(), maxQuestionOrder);
        }
示例#7
0
        public void AddToProjectCategory()
        {
            var projectCategoryService = new ProjectCategoryService(fixture.context);
            var projectCategory        = projectCategoryService.Create(Randomize.String());

            var service    = new QuestionTemplateService(fixture.context);
            var nActive    = service.ActiveQuestions(projectCategory).Count();
            var nTemplates = service.GetAll().Count();
            var template   = service.GetAll().First();

            var updatedQT = service.AddToProjectCategory(template.Id, projectCategory.Id);
            var updatedSP = projectCategoryService.Get(projectCategory.Id);

            Assert.True(updatedQT.ProjectCategories.Contains(updatedSP));
            Assert.True(updatedSP.QuestionTemplates.Contains(updatedQT));

            Assert.Equal(nActive + 1, service.ActiveQuestions(projectCategory).Count());
            Assert.Equal(nTemplates, service.GetAll().Count());

            /* Adding the same QuestionTemplate should fail */
            Assert.Throws <Exception>(() =>
                                      service.AddToProjectCategory(template.Id, projectCategory.Id)
                                      );
        }
示例#8
0
        public void DoNotReorderInactiveQuestionTemplate()
        {
            QuestionTemplateService       questionTemplateService = new QuestionTemplateService(fixture.context);
            IQueryable <QuestionTemplate> getAll = questionTemplateService.GetAll();
            // Edit a question template to make sure an inactive question template exists
            var originalQT = getAll.First();
            var updatedQT  = questionTemplateService.Edit(
                questionTemplate: originalQT,
                barrier:          originalQT.Barrier,
                organization:     Randomize.Organization(),
                text:             Randomize.String(),
                supportNotes:     Randomize.String(),
                status:           Status.Active
                );

            var inactiveQuestionTemplate = getAll
                                           .Where(qt => qt.Status == Status.Inactive)
                                           .First()
            ;

            QuestionTemplate resultingQuestionTemplate = questionTemplateService.ReorderQuestionTemplate(inactiveQuestionTemplate);

            Assert.Equal(inactiveQuestionTemplate.Order, resultingQuestionTemplate.Order);
        }
示例#9
0
        public void NonParcipantIsUnauthorized()
        {
            string AzureUniqueId = Randomize.Integer().ToString();

            AssertIsNotAuthorized(AzureUniqueId);
        }