public void Create()
        {
            EvaluationService evaluationService = new EvaluationService(_context);
            Evaluation        evaluation        = evaluationService.GetAll().First();

            ParticipantService participantService = new ParticipantService(_context);

            int nParticipantsBefore = participantService.GetAll().Count();

            participantService.Create("Create_id", evaluation, Organization.Engineering, Role.Participant);
            int nParticipantsAfter = participantService.GetAll().Count();

            Assert.Equal(nParticipantsBefore + 1, nParticipantsAfter);
        }
        public void GetQueryable()
        {
            ParticipantService       participantService   = new ParticipantService(_context);
            IQueryable <Participant> participantQueryable = participantService.GetAll();

            Assert.True(participantQueryable.Count() > 0);
        }
Exemple #3
0
        public Participant DeleteParticipant(string participantId)
        {
            Evaluation evaluation = _participantService.GetAll()
                                    .Where(p => p.Id.Equals(participantId))
                                    .Select(p => p.Evaluation)
                                    .First()
            ;

            Role[] canBePerformedBy = { Role.Facilitator, Role.OrganizationLead };
            AssertCanPerformMutation(evaluation, canBePerformedBy);

            Participant subject = _participantService.GetParticipant(participantId);

            /* Safeguard against deleting the last Facilitator */
            if (subject.Role.Equals(Role.Facilitator))
            {
                int facilitators = evaluation.Participants
                                   .Where(p => p.Role.Equals(Role.Facilitator))
                                   .Count()
                ;

                if (facilitators < 2)
                {
                    string msg = "Cannot delete last Facilitator in Evaluation";
                    throw new InvalidOperationException(msg);
                }
            }

            return(_participantService.Remove(participantId));
        }
Exemple #4
0
        /* Helper methods */

        protected int NumberOfParticipants(Evaluation evaluation)
        {
            int participants = _participantService
                               .GetAll()
                               .Where(p => p.Evaluation == evaluation)
                               .Count()
            ;

            return(participants);
        }
Exemple #5
0
        public void GetExists()
        {
            NoteService        noteService        = new NoteService(fixture.context);
            ParticipantService participantService = new ParticipantService(fixture.context);
            Participant        participant        = participantService.GetAll().First();
            ActionService      actionService      = new ActionService(fixture.context);
            Action             action             = actionService.GetAll().First();

            Note NoteCreate = noteService.Create(participant, "text", action);

            Note NoteGet = noteService.GetNote(NoteCreate.Id);

            Assert.Equal(NoteCreate, NoteGet);
        }
Exemple #6
0
        public void GetExists()
        {
            ClosingRemarkService closingRemarkService = new ClosingRemarkService(fixture.context);
            ParticipantService   participantService   = new ParticipantService(fixture.context);
            Participant          participant          = participantService.GetAll().First();
            ActionService        actionService        = new ActionService(fixture.context);
            Action action = actionService.GetAll().First();

            ClosingRemark ClosingRemarkCreate = closingRemarkService.Create(participant, "text", action);

            ClosingRemark ClosingRemarkGet = closingRemarkService.GetClosingRemark(ClosingRemarkCreate.Id);

            Assert.Equal(ClosingRemarkCreate, ClosingRemarkGet);
        }
Exemple #7
0
        public void GetExists()
        {
            ActionService      actionService      = new ActionService(_context);
            ParticipantService participantService = new ParticipantService(_context);
            Participant        participant        = participantService.GetAll().First();
            QuestionService    questionService    = new QuestionService(_context);
            Question           question           = questionService.GetAll().First();

            Action actionCreate = actionService.Create(participant, participant, "description", DateTimeOffset.UtcNow, "title", Priority.High, question);

            Action actionGet = actionService.GetAction(actionCreate.Id).First();

            Assert.Equal(actionCreate, actionGet);
        }
        public void GetExists()
        {
            AnswerService      answerService      = new AnswerService(_context);
            ParticipantService participantService = new ParticipantService(_context);
            Participant        participant        = participantService.GetAll().ToList()[1];
            QuestionService    questionService    = new QuestionService(_context);
            Question           question           = questionService.GetAll().First();

            Answer answerCreate = answerService.Create(participant, question, Severity.High, "test_answer");

            Answer answerGet = answerService.GetAnswer(answerCreate.Id);

            Assert.Equal(answerCreate, answerGet);
        }
Exemple #9
0
        public void Create()
        {
            ParticipantService participantService = new ParticipantService(fixture.context);
            Participant        participant        = participantService.GetAll().First();
            ActionService      actionService      = new ActionService(fixture.context);
            Action             action             = actionService.GetAll().First();

            NoteService noteService = new NoteService(fixture.context);
            int         nNoteBefore = noteService.GetAll().Count();

            noteService.Create(participant, "text", action);
            int nNotesAfter = noteService.GetAll().Count();

            Assert.Equal(nNoteBefore + 1, nNotesAfter);
        }
Exemple #10
0
        public void Create()
        {
            ParticipantService participantService = new ParticipantService(_context);
            Participant        participant        = participantService.GetAll().ToList()[0];
            QuestionService    questionService    = new QuestionService(_context);
            Question           question           = questionService.GetAll().First();

            AnswerService answerService = new AnswerService(_context);
            int           nAnswerBefore = answerService.GetAll().Count();

            answerService.Create(participant, question, Severity.High, "test_answer");
            int nAnswersAfter = answerService.GetAll().Count();

            Assert.Equal(nAnswerBefore + 1, nAnswersAfter);
        }
Exemple #11
0
        public void Create()
        {
            ParticipantService participantService = new ParticipantService(_context);
            Participant        participant        = participantService.GetAll().First();
            QuestionService    questionService    = new QuestionService(_context);
            Question           question           = questionService.GetAll().First();

            ActionService actionService = new ActionService(_context);
            int           nActionBefore = actionService.GetAll().Count();

            actionService.Create(participant, participant, "description", DateTimeOffset.UtcNow, "title", Priority.Low, question);
            int nActionsAfter = actionService.GetAll().Count();

            Assert.Equal(nActionBefore + 1, nActionsAfter);
        }
Exemple #12
0
        public void Create()
        {
            ParticipantService participantService = new ParticipantService(fixture.context);
            Participant        participant        = participantService.GetAll().First();
            ActionService      actionService      = new ActionService(fixture.context);
            Action             action             = actionService.GetAll().First();

            ClosingRemarkService closingRemarkService = new ClosingRemarkService(fixture.context);
            int nClosingRemarksBefore = closingRemarkService.GetAll().Count();

            closingRemarkService.Create(participant, "text", action);
            int nClosingRemarksAfter = closingRemarkService.GetAll().Count();

            Assert.Equal(nClosingRemarksBefore + 1, nClosingRemarksAfter);
        }
Exemple #13
0
        public void EditNote()
        {
            ParticipantService participantService = new ParticipantService(fixture.context);
            Participant        participant        = participantService.GetAll().First();

            ActionService actionService = new ActionService(fixture.context);
            Action        action        = actionService.GetAll().First();

            NoteService noteService = new NoteService(fixture.context);
            string      initialText = "initial text";
            Note        note        = noteService.Create(participant, initialText, action);
            string      noteId      = note.Id;

            string newText = "new text";

            noteService.EditNote(note, newText);

            Note resultingNote = noteService.GetNote(noteId);

            Assert.Equal(newText, resultingNote.Text);
        }
Exemple #14
0
        public void GetFromQuestionExists()
        {
            QuestionTemplateService questionTemplateService = new QuestionTemplateService(_context);
            QuestionTemplate        questionTemplate        = questionTemplateService.GetAll().First();

            EvaluationService evaluationService = new EvaluationService(_context);
            Evaluation        evaluation        = evaluationService.GetAll().First();

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

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

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

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

            Assert.Equal(answerCreate, answerGet);
        }
Exemple #15
0
        public void UpdateAnswer()
        {
            ParticipantService participantService = new ParticipantService(_context);
            Participant        participant        = participantService.GetAll().ToList()[2];

            QuestionService questionService = new QuestionService(_context);
            Question        question        = questionService.GetAll().First();

            AnswerService answerService = new AnswerService(_context);
            string        initialText   = "test answer";
            Answer        answer        = answerService.Create(participant, question, Severity.High, initialText);
            string        answerId      = answer.Id;

            string newText = "some different test answer";

            answerService.UpdateAnswer(answer, Severity.High, newText);

            Answer resultingAnswer = answerService.GetAnswer(answerId);

            Assert.Equal(newText, resultingAnswer.Text);
        }
Exemple #16
0
        public void EditAction()
        {
            ParticipantService participantService = new ParticipantService(_context);
            Participant        participant        = participantService.GetAll().First();

            QuestionService questionService = new QuestionService(_context);
            Question        question        = questionService.GetAll().First();

            ActionService actionService      = new ActionService(_context);
            string        initialDescription = "initial description";
            Action        action             = actionService.Create(participant, participant, initialDescription, DateTimeOffset.UtcNow, "title", Priority.Medium, question);
            string        actionId           = action.Id;

            string newDescription = "new description";

            actionService.EditAction(action, participant, newDescription, DateTimeOffset.UtcNow, "title", false, false, Priority.High);

            Action resultingAction = actionService.GetAction(actionId).First();

            Assert.Equal(newDescription, resultingAction.Description);
        }
Exemple #17
0
        public Task <ICollection <ParticipantModel> > GetAllTest([PexAssumeUnderTest] ParticipantService target)
        {
            Task <ICollection <ParticipantModel> > result = target.GetAll();

            return(result);
        }
Exemple #18
0
 public IQueryable <Participant> GetParticipants()
 {
     return(_participantService.GetAll());
 }