protected Action CreateAction( string questionId, string assignedToId, string description = null, System.DateTimeOffset?dueDate = null, Priority?priority = null, string title = null) { if (title == null) { title = Randomize.String(); } if (description == null) { description = Randomize.String(); } Action action = _mutation.CreateAction( questionId: questionId, assignedToId: assignedToId, description: description, dueDate: dueDate.GetValueOrDefault(System.DateTimeOffset.Now), priority: priority.GetValueOrDefault(Randomize.Priority()), title: title ); return(action); }
public void RemoveFromSeveralProjectCategories() { var projectCategoryService = new ProjectCategoryService(fixture.context); var projectCategory1 = projectCategoryService.Create(Randomize.String()); var projectCategory2 = projectCategoryService.Create(Randomize.String()); var projectCategoryIds = new List <string> { projectCategory1.Id, projectCategory2.Id }; var service = new QuestionTemplateService(fixture.context); var template = service.GetAll().First(); service.AddToProjectCategory(template.Id, projectCategory1.Id); service.AddToProjectCategory(template.Id, projectCategory2.Id); var nActiveFirstCategory = service.ActiveQuestions(projectCategory1).Count(); var nActiveSecondCategory = service.ActiveQuestions(projectCategory2).Count(); var nTemplates = service.GetAll().Count(); var updatedQT = service.RemoveFromProjectCategories(template.Id, projectCategoryIds); var updatedPC1 = projectCategoryService.Get(projectCategory1.Id); var updatedPC2 = projectCategoryService.Get(projectCategory2.Id); Assert.False(updatedQT.ProjectCategories.Contains(updatedPC1)); Assert.False(updatedQT.ProjectCategories.Contains(updatedPC2)); Assert.False(updatedPC1.QuestionTemplates.Contains(updatedQT)); Assert.False(updatedPC2.QuestionTemplates.Contains(updatedQT)); Assert.Equal(nActiveFirstCategory - 1, service.ActiveQuestions(projectCategory1).Count()); Assert.Equal(nActiveSecondCategory - 1, service.ActiveQuestions(projectCategory2).Count()); Assert.Equal(nTemplates, service.GetAll().Count()); }
protected Action EditAction( string actionId, string assignedToId, string description = null, System.DateTimeOffset?dueDate = null, Priority?priority = null, string title = null, bool onHold = false, bool completed = false) { if (title == null) { title = Randomize.String(); } if (description == null) { description = Randomize.String(); } Action action = _mutation.EditAction( actionId: actionId, assignedToId: assignedToId, description: description, dueDate: dueDate.GetValueOrDefault(System.DateTimeOffset.Now), priority: priority.GetValueOrDefault(Randomize.Priority()), title: title, onHold: onHold, completed: completed ); return(action); }
/* Mutation wrappers with default values */ protected Evaluation CreateEvaluation( string name = null, string projectId = null, string previousEvaluationId = null, string projectCategoryId = null) { if (name == null) { name = Randomize.String(); } if (projectId == null) { projectId = _project.Id; } if (previousEvaluationId == null) { previousEvaluationId = ""; } if (projectCategoryId == null) { projectCategoryId = _projectCategoryService.GetAll().First().Id; } Evaluation evaluation = _mutation.CreateEvaluation( name: name, projectId: projectId, previousEvaluationId: previousEvaluationId, projectCategoryId: projectCategoryId ); return(evaluation); }
public void RemoveFromProjectCategory() { var projectCategoryService = new ProjectCategoryService(fixture.context); var projectCategory = projectCategoryService.Create(Randomize.String()); var service = new QuestionTemplateService(fixture.context); var template = service.GetAll().First(); service.AddToProjectCategory(template.Id, projectCategory.Id); var nActive = service.ActiveQuestions(projectCategory).Count(); var nTemplates = service.GetAll().Count(); var updatedQT = service.RemoveFromProjectCategories(template.Id, new List <string> { projectCategory.Id }); var updatedPC = projectCategoryService.Get(projectCategory.Id); Assert.False(updatedQT.ProjectCategories.Contains(updatedPC)); Assert.False(updatedPC.QuestionTemplates.Contains(updatedQT)); Assert.Equal(nActive - 1, service.ActiveQuestions(projectCategory).Count()); Assert.Equal(nTemplates, service.GetAll().Count()); /* Removing the same QuestionTemplate should fail */ Assert.Throws <Exception>(() => service.RemoveFromProjectCategories(template.Id, new List <string> { projectCategory.Id }) ); }
public void CopyUsingCreate() { var service = new QuestionTemplateService(fixture.context); var questionTemplateToCopy = service.Create( barrier: Randomize.Barrier(), organization: Randomize.Organization(), text: Randomize.String(), supportNotes: Randomize.String() ); int maxAdminOrder = service.GetAll() .Where(qt => qt.Status == Status.Active) .Max(qt => qt.AdminOrder) ; var newQuestionTemplate = service.Create( barrier: questionTemplateToCopy.Barrier, organization: questionTemplateToCopy.Organization, text: questionTemplateToCopy.Text, supportNotes: questionTemplateToCopy.SupportNotes, newOrder: questionTemplateToCopy.Order + 1 ); Assert.Equal(questionTemplateToCopy.Order + 1, newQuestionTemplate.Order); Assert.Equal(maxAdminOrder + 1, newQuestionTemplate.AdminOrder); }
private void AssertIsNotAuthorized(string azureUniqueId) { _authService.LoginUser(azureUniqueId); Assert.Throws <UnauthorizedAccessException>(() => _mutation.SetSummary( evaluationId: _evaluation.Id, summary: Randomize.String() ) ); }
public void Create() { var service = new ProjectCategoryService(fixture.context); int nCategories = service.GetAll().Count(); service.Create(Randomize.String()); Assert.Equal(nCategories + 1, service.GetAll().Count()); }
public void GetNonExisting() { var service = new ProjectCategoryService(fixture.context); var nonExistingId = Randomize.String(); Assert.Throws <NotFoundInDBException>( () => service.Get(nonExistingId) ); }
public void GetExising() { var service = new ProjectCategoryService(fixture.context); var name = Randomize.String(); var exisingId = service.Create(name).Id; var exists = service.Get(exisingId); Assert.Equal(name, exists.Name); }
private void AssertIsNotAuthorized(string azureUniqueId) { _authService.LoginUser(azureUniqueId); Assert.Throws <UnauthorizedAccessException>(() => CreateClosingRemark( actionId: _action.Id, text: Randomize.String() ) ); }
/* Helper methods */ private void AssertCanCreate(Participant user) { _authService.LoginUser(user); int notes = NumberOfClosingRemarks(_action); CreateClosingRemark( actionId: _action.Id, text: Randomize.String() ); Assert.True(NumberOfClosingRemarks(_action) == notes + 1); }
public void DeleteQuestionTemplate() { var service = new QuestionTemplateService(fixture.context); Barrier barrier = Randomize.Barrier(); var questionTemplateToDelete = service.Create( barrier: barrier, organization: Randomize.Organization(), text: Randomize.String(), supportNotes: Randomize.String() ); var projectCategory = new ProjectCategoryService(fixture.context).GetAll().First(); questionTemplateToDelete = service.AddToProjectCategory(questionTemplateToDelete.Id, projectCategory.Id); int maxOrderActive = service.GetAll() .Where(qt => qt.Status == Status.Active) .Max(qt => qt.Order) ; int maxBarrierOrder = service.GetAll() .Where(qt => qt.Status == Status.Active) .Where(qt => qt.Barrier == barrier) .Max(qt => qt.Order) ; int maxAdminOrder = service.GetAll() .Where(qt => qt.Status == Status.Active) .Max(qt => qt.AdminOrder) ; var deletedQuestionTemplate = service.Delete(questionTemplateToDelete); int maxOrderActiveAfter = service.GetAll() .Where(qt => qt.Status == Status.Active) .Max(qt => qt.Order) ; int maxBarrierOrderAfter = service.GetAll() .Where(qt => qt.Status == Status.Active) .Where(qt => qt.Barrier == barrier) .Max(qt => qt.Order) ; int maxAdminOrderAfter = service.GetAll() .Where(qt => qt.Status == Status.Active) .Max(qt => qt.AdminOrder) ; int maxOrder = fixture.context.QuestionTemplates.Max(qt => qt.Order); Assert.Equal(maxOrderActive - 1, maxOrderActiveAfter); Assert.Equal(maxBarrierOrder - 1, maxBarrierOrderAfter); Assert.Equal(maxAdminOrder - 1, maxAdminOrderAfter); Assert.Equal(deletedQuestionTemplate.Order, maxOrder); Assert.True(deletedQuestionTemplate.Status == Status.Voided); Assert.Equal(deletedQuestionTemplate.ProjectCategories, questionTemplateToDelete.ProjectCategories); }
public void CopyFrom() { var service = new ProjectCategoryService(fixture.context); var nProjectCategories = service.GetAll().Count(); var other = service.GetAll().First(); var nTemplates = other.QuestionTemplates.Count(); var projectCategory = service.CopyFrom(Randomize.String(), other); Assert.Equal(nProjectCategories + 1, service.GetAll().Count()); Assert.Equal(nTemplates, projectCategory.QuestionTemplates.Count()); }
/* Helper methods */ private void AssertCanSet(Participant user) { _authService.LoginUser(user); string summary = Randomize.String(); _mutation.SetSummary( evaluationId: _evaluation.Id, summary: summary ); Assert.True(_evaluation.Summary == summary); }
protected Note CreateNote( string actionId, string text = null) { if (text == null) { text = Randomize.String(); } Note note = _mutation.CreateNote( actionId: actionId, text: text ); return(note); }
protected ClosingRemark CreateClosingRemark( string actionId, string text = null) { if (text == null) { text = Randomize.String(); } ClosingRemark remark = _mutation.CreateClosingRemark( actionId: actionId, text: text ); return(remark); }
/* Helper methods */ private void AssertCanEdit(Participant user) { _authService.LoginUser(user); int answers = NumberOfActions(_question); string description = _action.Description; string actionId = _action.Id; var action = EditAction( actionId: actionId, assignedToId: Randomize.Value <Participant>(_evaluation.Participants).Id, description: Randomize.String() ); Assert.True(NumberOfActions(_question) == answers); Assert.True(actionId == action.Id); Assert.False(description == action.Description); }
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); }
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); }
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()); }
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); }
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); }
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); }
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) ); }