private void btnValidate_Click(object sender, RoutedEventArgs e) { lvOutput.Items.Clear(); var validator = new ObjectValidator(typeof(TrainingPlan)); var result1 = validator.Validate(Context.Item); if (!result1.IsValid) { foreach (var message in result1) { addOutputItem((BAGlobalObject)(message.Target != null ? message.Target : Context.Item), message.Message, TrainingPlanCheckItemStatus.Error); } return; } var pack = TrainingPlanPack.Create(TrainingPlan, ExercisesReposidory.Instance.Items); SplitPlanChecker checker = new SplitPlanChecker(pack); var result = checker.Check(ExercisesReposidory.Instance.Items); foreach (var resultItem in result.Results) { addOutputItem(resultItem.TrainingPlanBase, StrengthTrainingEntryStrings.ResourceManager.GetString(resultItem.ResourceKey), resultItem.Status); } }
private void checkSingle(TrainingPlan plan, BAGlobalObject planItem, TrainingPlanCheckItemStatus status, string resourceKey) { //Dictionary<Guid, ExerciseDTO> exerciseDtos = ObjectsConverter.ToExerciseDTO(exercises.Values).ToDictionary(t => t.GlobalId); Dictionary <Guid, ExerciseDTO> exerciseDtos = exercises.Values.Map <IList <ExerciseDTO> >().ToDictionary(t => t.GlobalId); TrainingPlanPack pack = TrainingPlanPack.Create(plan, exerciseDtos); SplitPlanChecker checker = new SplitPlanChecker(pack); var result = checker.Check(exerciseDtos); Assert.AreEqual(1, result.Results.Count); Assert.AreEqual(status, result.Results[0].Status); Assert.AreEqual(resourceKey, result.Results[0].ResourceKey); Assert.AreEqual(planItem.GlobalId, result.Results[0].TrainingPlanBase.GlobalId); }
public void TestTwoIsolationExerciseBeforeCompoud() { TrainingPlan plan = new TrainingPlan(); plan.RestSeconds = 60; plan.Name = "name"; plan.Author = "author"; plan.TrainingType = TrainingType.Split; var day = new TrainingPlanDay(); day.Name = "day1"; plan.AddDay(day); TrainingPlanEntry entryIsolated = new TrainingPlanEntry(); entryIsolated.Exercise = new ExerciseLightDTO() { GlobalId = new Guid("01C796E2-0119-4F95-9A9A-79F2890DF658") }; day.AddEntry(entryIsolated); entryIsolated.Sets.Add(new TrainingPlanSerie(10)); TrainingPlanEntry secondIsolated = new TrainingPlanEntry(); secondIsolated.Exercise = new ExerciseLightDTO() { GlobalId = new Guid("D6562C2A-BD74-46BE-8398-57B56BD698D5") }; day.AddEntry(secondIsolated); secondIsolated.Sets.Add(new TrainingPlanSerie(10)); TrainingPlanEntry entryCompoud = new TrainingPlanEntry(); entryCompoud.Exercise = new ExerciseLightDTO() { GlobalId = new Guid("9934E9E3-50DC-4B34-8B67-092084894740") }; day.AddEntry(entryCompoud); entryCompoud.Sets.Add(new TrainingPlanSerie(10)); //Dictionary<Guid, ExerciseDTO> exerciseDtos = ObjectsConverter.ToExerciseDTO(exercises.Values).ToDictionary(t => t.GlobalId); Dictionary <Guid, ExerciseDTO> exerciseDtos = exercises.Values.Map <IList <ExerciseDTO> >().ToDictionary(t => t.GlobalId); TrainingPlanPack pack = TrainingPlanPack.Create(plan, exerciseDtos); SplitPlanChecker checker = new SplitPlanChecker(pack); var result = checker.Check(exerciseDtos); Assert.AreEqual(2, result.Results.Count); Assert.AreEqual(TrainingPlanCheckItemStatus.Information, result.Results[0].Status); Assert.AreEqual("Split_IsolationExerciseBeforeCompoud", result.Results[0].ResourceKey); Assert.AreEqual(entryIsolated.GlobalId, result.Results[0].TrainingPlanBase.GlobalId); Assert.AreEqual(TrainingPlanCheckItemStatus.Information, result.Results[1].Status); Assert.AreEqual("Split_IsolationExerciseBeforeCompoud", result.Results[1].ResourceKey); Assert.AreEqual(secondIsolated.GlobalId, result.Results[1].TrainingPlanBase.GlobalId); }
private void btnValidate_Click(object sender, EventArgs e) { updateTrainingPlan(); var pack = TrainingPlanPack.Create(TrainingPlan, ObjectsReposidory.Exercises); SplitPlanChecker checker = new SplitPlanChecker(pack); var result = checker.Check(ObjectsReposidory.Exercises); lvOutput.Items.Clear(); foreach (var resultItem in result.Results) { List <string> texts = new List <string>(); texts.Add(LocalizedPropertyGridStrings.ResourceManager.GetString(resultItem.ResourceKey)); texts.AddRange(getNameAndType(resultItem.TrainingPlanBase)); ListViewItem item = new ListViewItem(texts.ToArray()); item.Tag = resultItem.TrainingPlanBase; item.ImageKey = resultItem.Status.ToString(); lvOutput.Items.Add(item); } }