public StudyDto CreaStudyDto() { var teamDto = new TeamDto { Id = 1 }; var criteria1 = new CriteriaDto { Name = "Name1", Rule = CriteriaDto.CriteriaRule.SmallerThan, DataMatch = new[] {"2000"}, DataType = DataFieldDto.DataType.String, Description = "Check if the year is before 2000" }; var criteria2 = new CriteriaDto { Name = "Is about...", DataType = DataFieldDto.DataType.Boolean, Rule = CriteriaDto.CriteriaRule.Equals, DataMatch = new[] {"true"}, Description = "Check if the item is about snails." }; var stage1 = new StageDto { Name = "stage1", Criteria = criteria1, DistributionRule = StageDto.Distribution.HundredPercentOverlap, ReviewerIDs = new[] {1, 2}, ValidatorIDs = new[] {3}, VisibleFields = new[] {StageDto.FieldType.Title, StageDto.FieldType.Author} }; var stage2 = new StageDto { Name = "stage2", Criteria = criteria2, DistributionRule = StageDto.Distribution.HundredPercentOverlap, ReviewerIDs = new[] {3, 2}, ValidatorIDs = new[] {4}, VisibleFields = new[] {StageDto.FieldType.Title, StageDto.FieldType.Author} }; var studyDto = new StudyDto { Name = "testStudy", Team = teamDto, Items = Resources.bibtex, Stages = new[] {stage1, stage2} }; return studyDto; }
public StageDto(Stage stage) { Name = stage.Name; Id = stage.ID; Criteria = new CriteriaDto(stage.Criteria.ElementAt(0)); ReviewerIDs = (from u in stage.Users where u.StudyRole == UserStudies.Role.Reviewer select u.ID).ToArray(); ValidatorIDs = (from u in stage.Users where u.StudyRole == UserStudies.Role.Validator select u.ID).ToArray(); DistributionRule = (Distribution) Enum.Parse(typeof (Stage.Distribution), stage.DistributionRule.ToString()); VisibleFields = stage.VisibleFields.Select( vf => (FieldType) Enum.Parse(typeof (Models.FieldType.TypEField), vf.Type.ToString())).ToArray(); }
public void UpdateStudyTest() { //Arrange InitializeStudyDb(); var study = _manager.GetStudy(1); var criteria1 = new CriteriaDto { Name = "updatedName", Rule = CriteriaDto.CriteriaRule.SmallerThan, DataMatch = new[] {"2000"}, DataType = DataFieldDto.DataType.String, Description = "Check if the year is before 2000" }; var stage1 = new StageDto { Name = "updatedStage", Criteria = criteria1, DistributionRule = StageDto.Distribution.HundredPercentOverlap, ReviewerIDs = new[] {1, 2}, ValidatorIDs = new[] {3}, VisibleFields = new[] {StageDto.FieldType.Title, StageDto.FieldType.Author} }; //Action study.Name = "updatedName"; var tempStages = study.Stages.ToList(); tempStages.Add(stage1); study.Stages = tempStages.ToArray(); _manager.UpdateStudy(1, study); var result = _manager.GetStudy(1); //Assert Assert.AreEqual(1, result.Id); Assert.AreEqual("updatedName", result.Name); Assert.AreEqual(3, result.Stages.Length); Assert.AreEqual("updatedStage", result.Stages[2].Name); }