Exemplo n.º 1
0
 public TreeEventViewModel([NotNull] TreeEvent treeEvent, [NotNull] EventTreeViewModel parentEventTreeViewModel, [NotNull] ProjectManipulationService projectManipulationService)
 {
     this.projectManipulationService = projectManipulationService;
     TreeEvent = treeEvent;
     ParentEventTreeViewModel   = parentEventTreeViewModel;
     treeEvent.PropertyChanged += TreeEventPropertyChanged;
 }
        public void RemoveHydraulicConditionDoesNotChangeClassEstimatesNoExperts()
        {
            var treeEvent = new TreeEvent();
            var hydraulicConditionToRemove = new HydraulicCondition(1.0, (Probability)0.01, 1, 1);
            var hydraulicCondition2        = new HydraulicCondition(2.0, (Probability)0.001, 1, 1);
            var project = new Project
            {
                EventTrees =
                {
                    new EventTree
                    {
                        MainTreeEvent = treeEvent
                    }
                },
                HydraulicConditions =
                {
                    hydraulicConditionToRemove,
                    hydraulicCondition2,
                }
            };
            var projectManipulationService = new ProjectManipulationService(project);

            Assert.AreEqual(0, treeEvent.ClassesProbabilitySpecification.Count);

            projectManipulationService.RemoveHydraulicCondition(hydraulicConditionToRemove);

            Assert.AreEqual(1, project.HydraulicConditions.Count);
            Assert.AreEqual(hydraulicCondition2, project.HydraulicConditions.First());
            Assert.AreEqual(0, treeEvent.ClassesProbabilitySpecification.Count);
        }
        public void RemoveExpertDoesNotChangeClassEstimatesNoHydraulicConditions()
        {
            var treeEvent      = new TreeEvent();
            var expertToRemove = new Expert();
            var otherExpert    = new Expert();
            var project        = new Project
            {
                EventTrees =
                {
                    new EventTree
                    {
                        MainTreeEvent = treeEvent
                    }
                },
                Experts =
                {
                    expertToRemove,
                    otherExpert
                }
            };
            var projectManipulationService = new ProjectManipulationService(project);

            Assert.AreEqual(0, treeEvent.ClassesProbabilitySpecification.Count);

            projectManipulationService.RemoveExpert(expertToRemove);

            Assert.AreEqual(1, project.Experts.Count);
            Assert.AreEqual(otherExpert, project.Experts.First());
            Assert.AreEqual(0, treeEvent.ClassesProbabilitySpecification.Count);
        }
Exemplo n.º 4
0
        public ProjectViewModel([NotNull] Project project)
        {
            BusyIndicator = StorageState.Idle;

            Project = project;
            projectManipulationService = new ProjectManipulationService(project);

            var eventTreeViewModels = new ObservableCollection <EventTreeViewModel>(project.EventTrees.Select(te =>
            {
                var eventTreeViewModel = new EventTreeViewModel(te, projectManipulationService)
                {
                    EstimationSpecificationViewModelFactory = new EstimationSpecificationViewModelFactory(project)
                };
                eventTreeViewModel.PropertyChanged += EventTreeViewModelPropertyChanged;
                return(eventTreeViewModel);
            }));

            EventTrees             = eventTreeViewModels;
            addTreeEventCommand    = new AddTreeEventCommand(this);
            removeTreeEventCommand = new RemoveTreeEventCommand(this);

            expertViewModels = new ObservableCollection <ExpertViewModel>(Project.Experts.Select(e => new ExpertViewModel(e)));
            expertViewModels.CollectionChanged += ExpertViewModelsCollectionChanged;

            hydraulicsViewModels = new ObservableCollection <HydraulicConditionViewModel>(Project.HydraulicConditions.Select(e => new HydraulicConditionViewModel(e)));
            hydraulicsViewModels.CollectionChanged += HydraulicsViewModelsCollectionChanged;

            project.EventTrees.CollectionChanged += EventTreesCollectionChanged;

            SelectedEventTreeFiltered = EventTrees.FirstOrDefault();
            foreach (var eventTreeViewModel in EventTrees)
            {
                eventTreeViewModel.SelectedTreeEvent = eventTreeViewModel.MainTreeEventViewModel;
            }
        }
Exemplo n.º 5
0
        public EventTreeViewModel()
        {
            var project = new Project();

            projectManipulationService = new ProjectManipulationService(project);
            EventTree = project.EventTrees.First();
            EventTree.PropertyChanged += EventTreePropertyChanged;
        }
        public void AddExpertChangesClassEstimatesWithHydraulicConditions()
        {
            var treeEvent = new TreeEvent();
            var project   = new Project
            {
                EventTrees = { new EventTree
                               {
                                   MainTreeEvent = treeEvent
                               } },
                HydraulicConditions =
                {
                    new HydraulicCondition(1.0, (Probability)0.01,  1, 1),
                    new HydraulicCondition(2.0, (Probability)0.001, 1, 1),
                }
            };
            var projectManipulationService = new ProjectManipulationService(project);

            Assert.AreEqual(0, treeEvent.ClassesProbabilitySpecification.Count);

            var expert = new Expert();

            projectManipulationService.AddExpert(expert);

            Assert.AreEqual(1, project.Experts.Count);
            Assert.AreEqual(expert, project.Experts.First());
            Assert.AreEqual(2, treeEvent.ClassesProbabilitySpecification.Count);
            var firstSpecification = treeEvent.ClassesProbabilitySpecification.First();

            Assert.AreEqual(expert, firstSpecification.Expert);
            Assert.Contains(firstSpecification.HydraulicCondition, project.HydraulicConditions);

            var secondSpecification = treeEvent.ClassesProbabilitySpecification.Last();

            Assert.AreEqual(expert, secondSpecification.Expert);
            Assert.Contains(secondSpecification.HydraulicCondition, project.HydraulicConditions);

            Assert.AreNotEqual(firstSpecification.HydraulicCondition, secondSpecification.HydraulicCondition);
        }
        public void RemoveExpertChangesClassEstimatesWithHydraulicConditions()
        {
            var expertToRemove      = new Expert();
            var otherExpert         = new Expert();
            var hydraulicCondition1 = new HydraulicCondition(1.0, (Probability)0.01, 1, 1);
            var hydraulicCondition2 = new HydraulicCondition(2.0, (Probability)0.001, 1, 1);
            var treeEvent           = new TreeEvent
            {
                ClassesProbabilitySpecification =
                {
                    new ExpertClassEstimation {
                        Expert = expertToRemove, HydraulicCondition = hydraulicCondition1
                    },
                    new ExpertClassEstimation {
                        Expert = expertToRemove, HydraulicCondition = hydraulicCondition2
                    },
                    new ExpertClassEstimation {
                        Expert = otherExpert, HydraulicCondition = hydraulicCondition1
                    },
                    new ExpertClassEstimation {
                        Expert = otherExpert, HydraulicCondition = hydraulicCondition2
                    }
                }
            };
            var project = new Project
            {
                EventTrees =
                {
                    new EventTree
                    {
                        MainTreeEvent = treeEvent
                    }
                },
                Experts =
                {
                    expertToRemove,
                    otherExpert
                },
                HydraulicConditions =
                {
                    hydraulicCondition1,
                    hydraulicCondition2,
                }
            };
            var projectManipulationService = new ProjectManipulationService(project);

            Assert.AreEqual(4, treeEvent.ClassesProbabilitySpecification.Count);

            projectManipulationService.RemoveExpert(expertToRemove);

            Assert.AreEqual(1, project.Experts.Count);
            Assert.AreEqual(otherExpert, project.Experts.First());
            Assert.AreEqual(2, treeEvent.ClassesProbabilitySpecification.Count);

            var firstSpecification = treeEvent.ClassesProbabilitySpecification.First();

            Assert.AreEqual(otherExpert, firstSpecification.Expert);
            Assert.AreEqual(hydraulicCondition1, firstSpecification.HydraulicCondition);
            Assert.Contains(firstSpecification.HydraulicCondition, project.HydraulicConditions);

            var secondSpecification = treeEvent.ClassesProbabilitySpecification.Last();

            Assert.AreEqual(otherExpert, secondSpecification.Expert);
            Assert.AreEqual(hydraulicCondition2, secondSpecification.HydraulicCondition);
            Assert.Contains(secondSpecification.HydraulicCondition, project.HydraulicConditions);

            Assert.AreNotEqual(firstSpecification.HydraulicCondition, secondSpecification.HydraulicCondition);
        }
Exemplo n.º 8
0
 public EventTreeViewModel([NotNull] EventTree eventTree, ProjectManipulationService projectManipulationService)
 {
     EventTree = eventTree;
     this.projectManipulationService = projectManipulationService;
     eventTree.PropertyChanged      += EventTreePropertyChanged;
 }