コード例 #1
0
        public void Initialize()
        {
            ServicesHelper.RegisterMockServices();

            //Arbre initial :
            //  G1 1
            //      T1 1.1
            //      T2 1.2
            //          T21 1.2.1
            //          T22 1.2.2
            //      T3 1.3
            //          T31 1.3.1
            //      T4 1.4

            _g1 = new KAction()
            {
                Label = "G1", WBS = "1"
            };
            _t1 = new KAction()
            {
                Label = "T1", WBS = "1.1"
            };
            _t2 = new KAction()
            {
                Label = "T2", WBS = "1.2"
            };
            _t21 = new KAction()
            {
                Label = "T21", WBS = "1.2.1"
            };
            _t22 = new KAction()
            {
                Label = "T22", WBS = "1.2.2"
            };
            _t3 = new KAction()
            {
                Label = "T3", WBS = "1.3"
            };
            _t31 = new KAction()
            {
                Label = "T31", WBS = "1.3.1"
            };
            _t4 = new KAction()
            {
                Label = "T4", WBS = "1.4"
            };

            _actions = new KAction[] { _g1, _t1, _t2, _t21, _t22, _t3, _t31, _t4 };

            _collection = new BulkObservableCollection <DataTreeGridItem>();

            _manager = new GridActionsManager(_collection, v => _currentItem = v, null);
            _manager.ChangeView(GanttGridView.WBS, null);
        }
コード例 #2
0
        /// <summary>
        /// Crée l'ActionManager.
        /// </summary>
        private void CreateManager()
        {
            _collection = new BulkObservableCollection <DataTreeGridItem>();

            var manager = new GridActionsManager(_collection, null, null);

            manager.ChangeView(GanttGridView.WBS, null);

            manager.RegisterInitialActions(_actions);
            manager.FixPredecessorsSuccessorsTimings();
        }
コード例 #3
0
        public void TestCanAddPredecessor()
        {
            var t1 = new KAction()
            {
                Label = "T1", WBS = "1"
            };
            var g1 = new KAction()
            {
                Label = "G1", WBS = "2"
            };
            var t2 = new KAction()
            {
                Label = "T2", WBS = "2.1"
            };
            var t3 = new KAction()
            {
                Label = "T3", WBS = "2.2"
            };
            var t4 = new KAction()
            {
                Label = "T4", WBS = "3"
            };
            var t5 = new KAction()
            {
                Label = "T5", WBS = "4"
            };

            var actions = new List <KAction>()
            {
                t1, g1, t2, t3, t4, t5
            };

            t3.Predecessors.Add(t1);
            t3.Predecessors.Add(t2);
            t4.Predecessors.Add(t3);
            t5.Predecessors.Add(t3);

            var collection = new BulkObservableCollection <DataTreeGridItem>();

            var manager = new GridActionsManager(collection, null, null);

            manager.ChangeView(GanttGridView.WBS, null);

            manager.RegisterInitialActions(actions);

            Assert.IsFalse(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), t1, t1));
            Assert.IsFalse(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), t1, t3));
            Assert.IsFalse(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), g1, t3));

            Assert.IsTrue(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), t4, t1));
            Assert.IsTrue(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), t5, t1));
            Assert.IsTrue(ActionsTimingsMoveManagement.CheckCanAddPredecessor(manager.GetActionsSortedByWBS(), t2, t1));
        }
コード例 #4
0
        public void TestGetCriticalPath3()
        {
            // Prédecesseurs multiples
            var t1 = new KAction()
            {
                Label = "T1", WBS = "1", BuildStart = 0, BuildDuration = 2
            };
            var t2 = new KAction()
            {
                Label = "T2", WBS = "2", BuildStart = 0, BuildDuration = 3
            };
            var t3 = new KAction()
            {
                Label = "T3", WBS = "3", BuildStart = 0, BuildDuration = 4
            };
            var t4 = new KAction()
            {
                Label = "T4", WBS = "4", BuildStart = 0, BuildDuration = 2
            };
            var t5 = new KAction()
            {
                Label = "T5", WBS = "5", BuildStart = 0, BuildDuration = 2
            };

            var actions = new List <KAction>()
            {
                t1, t2, t3, t4, t5
            };

            t3.Predecessors.Add(t1);
            t3.Predecessors.Add(t2);
            t4.Predecessors.Add(t3);
            t5.Predecessors.Add(t3);

            var collection = new BulkObservableCollection <DataTreeGridItem>();

            var manager = new GridActionsManager(collection, null, null);

            manager.ChangeView(GanttGridView.WBS, null);

            manager.RegisterInitialActions(actions);
            manager.FixPredecessorsSuccessorsTimings();

            var actual   = manager.UpdateCriticalPath().ToList();
            var expected = new List <ActionPath>()
            {
                actual.First(c => c.Action == t2),
                actual.First(c => c.Action == t3),
                actual.First(c => c.Action == t4)
            };

            CollectionAssert.AreEqual(expected, actual);
        }
コード例 #5
0
        public void TestGetCriticalPath1()
        {
            var g1 = new KAction()
            {
                Label = "G1", WBS = "1"
            };
            var t1 = new KAction()
            {
                Label = "T1", WBS = "1.1", BuildStart = 0, BuildDuration = 2
            };
            var t2 = new KAction()
            {
                Label = "T2", WBS = "1.2"
            };
            var t21 = new KAction()
            {
                Label = "T21", WBS = "1.2.1", BuildStart = 0, BuildDuration = 2
            };
            var t22 = new KAction()
            {
                Label = "T22", WBS = "1.2.2", BuildStart = 0, BuildDuration = 2
            };

            var actions = new List <KAction>()
            {
                g1, t1, t2, t21, t22
            };

            t22.Predecessors.Add(t1);
            t21.Predecessors.Add(t22);

            var collection = new BulkObservableCollection <DataTreeGridItem>();

            var manager = new GridActionsManager(collection, null, null);

            manager.ChangeView(GanttGridView.WBS, null);

            manager.RegisterInitialActions(actions);
            manager.FixPredecessorsSuccessorsTimings();

            var actual = manager.UpdateCriticalPath().ToList();
            //var actual = manager.GetCriticalPathv2().ToList();
            var expected = new List <ActionPath>()
            {
                actual.First(c => c.Action == t1),
                actual.First(c => c.Action == t22),
                actual.First(c => c.Action == t21)
            };

            CollectionAssert.AreEqual(expected, actual);
        }
コード例 #6
0
        public void TestFixWBS()
        {
            var g1 = new KAction()
            {
                Label = "G1", WBS = "1"
            };
            var t1 = new KAction()
            {
                Label = "T1", WBS = "1.2"
            };
            var t2 = new KAction()
            {
                Label = "T2", WBS = "1.3"
            };
            var t21 = new KAction()
            {
                Label = "T21", WBS = "1.3.0"
            };
            var t22 = new KAction()
            {
                Label = "T22", WBS = "1.3.2"
            };

            var actions = new List <KAction>()
            {
                g1, t1, t2, t21, t22
            };

            var collection = new BulkObservableCollection <DataTreeGridItem>();

            var manager = new GridActionsManager(collection, null, null);

            manager.ChangeView(GanttGridView.WBS, null);

            manager.RegisterInitialActions(actions);

            manager.FixAllWBS();

            AssertWBS(g1, "1");
            AssertWBS(t1, "1.1");
            AssertWBS(t2, "1.2");
            AssertWBS(t21, "1.2.1");
            AssertWBS(t22, "1.2.2");
        }
コード例 #7
0
        public void TestGetCriticalPath_Bug1545_Equivalent()
        {
            var t1 = new KAction()
            {
                Label = "T1", WBS = "1", BuildStart = 0, BuildDuration = 1
            };
            var t2 = new KAction()
            {
                Label = "T2", WBS = "2", BuildStart = 0, BuildDuration = 0
            };
            var t3 = new KAction()
            {
                Label = "T3", WBS = "3", BuildStart = 2, BuildDuration = 1
            };

            var actions = new List <KAction>()
            {
                t1, t2, t3
            };

            t2.Predecessors.Add(t1);

            var collection = new BulkObservableCollection <DataTreeGridItem>();

            var manager = new GridActionsManager(collection, null, null);

            manager.ChangeView(GanttGridView.WBS, null);

            manager.RegisterInitialActions(actions);
            manager.FixPredecessorsSuccessorsTimings();

            var actual   = manager.UpdateCriticalPath().ToList();
            var expected = new List <ActionPath>()
            {
                actual.First(c => c.Action == t1),
                actual.First(c => c.Action == t2),
                actual.First(c => c.Action == t3)
            };

            CollectionAssert.AreEqual(expected, actual);
        }
コード例 #8
0
        public void GanttGridTests()
        {
            KProcess.Ksmed.Business.Tests.SampleData.ClearDatabaseThenImportDefaultProject();

            // On récupère les données
            var service = new AnalyzeService();

            var mre = new ManualResetEvent(false);

            var collection     = new BulkObservableCollection <DataTreeGridItem>();
            var actionsManager = new GridActionsManager(collection, null, null);

            actionsManager.ChangeView(Core.GanttGridView.WBS, null);

            var categories = new BulkObservableCollection <ActionCategory>();

            Video[]    videos    = null;
            Scenario[] scenarios = null;
            Scenario   scenario  = null;

            Exception ex = null;

            service.GetAcquireData(SampleData.GetProjectId(),
                                   data =>
            {
                categories.AddRange(data.Categories);
                videos = data.Videos;

                scenarios = data.Scenarios;

                scenario = scenarios.First();

                foreach (var action in scenario.Actions)
                {
                    action.StartTracking();
                }

                mre.Set();
            },
                                   e =>
            {
                ex = e;
                mre.Set();
            });

            mre.WaitOne();

            AssertExt.IsExceptionNull(ex);

            actionsManager.RegisterInitialActions(scenario.Actions);

            Assert.IsTrue(scenario.Actions.Count > 1);
            Assert.IsTrue(collection.Count > 1);
            Assert.IsTrue(videos.Length > 0);
            Assert.IsTrue(scenario.Actions[1].Video != null);

            // Capturons l'état de toutes les éléments
            var originalValues = GetCurrentValues(scenario.Actions, categories, videos);

            Modify(actionsManager, collection, scenario);

            var modifiedValues = GetCurrentValues(scenario.Actions, categories, videos);

            Assert.IsFalse(AreDumpsEqual(originalValues, modifiedValues));

            // On annule les changements
            actionsManager.UnregisterAllItems();
            ObjectWithChangeTrackerExtensions.CancelChanges(scenario.Actions, categories, videos);

            var revertedValues = GetCurrentValues(scenario.Actions, categories, videos);

            Assert.IsTrue(AreDumpsEqual(originalValues, revertedValues));



            // On recommence
            actionsManager.RegisterInitialActions(scenario.Actions);
            Modify(actionsManager, collection, scenario);

            modifiedValues = GetCurrentValues(scenario.Actions, categories, videos);

            Assert.IsFalse(AreDumpsEqual(originalValues, modifiedValues));

            // On annule les changements
            actionsManager.UnregisterAllItems();
            ObjectWithChangeTrackerExtensions.CancelChanges(scenario.Actions, categories, videos);

            revertedValues = GetCurrentValues(scenario.Actions, categories, videos);

            Assert.IsTrue(AreDumpsEqual(originalValues, revertedValues));
        }
コード例 #9
0
        public void TestDelete()
        {
            // Voilà une représentation des tâches
            // -- T1
            //   -- T2
            //     -- T3
            //   - T4

            // Et les précédesseurs :
            // T3 -> T2 -> T1,
            // T3 -> T4 -> T1

            // Le test va consister à supprimer T2
            // Quand on le supprime, T3 devrait se décaller de 1 vers la droite que correspondre au précédesseur T4

            var t1 = new KAction
            {
                Label       = "T1",
                WBS         = "1",
                Start       = 0,
                Finish      = 1,
                BuildStart  = 0,
                BuildFinish = 2,
            };

            var t2 = new KAction
            {
                Label        = "T2",
                WBS          = "2",
                Start        = 0,
                Finish       = 1,
                BuildStart   = 0,
                BuildFinish  = 2,
                Predecessors = new TrackableCollection <KAction>()
                {
                    t1
                },
            };

            var t4 = new KAction
            {
                Label        = "T4",
                WBS          = "4",
                Start        = 0,
                Finish       = 1,
                BuildStart   = 0,
                BuildFinish  = 1,
                Predecessors = new TrackableCollection <KAction>()
                {
                    t1
                },
            };

            var t3 = new KAction
            {
                Label        = "T3",
                WBS          = "3",
                Start        = 0,
                Finish       = 1,
                BuildStart   = 0,
                BuildFinish  = 2,
                Predecessors = new TrackableCollection <KAction>()
                {
                    t2, t4
                },
            };


            var actions = new List <KAction>()
            {
                t1, t2, t3, t4
            };

            var collection = new BulkObservableCollection <DataTreeGridItem>();

            var manager = new GridActionsManager(collection, null, null);

            manager.ChangeView(GanttGridView.WBS, null);

            manager.RegisterInitialActions(actions);
            manager.FixPredecessorsSuccessorsTimings();

            Assert.AreEqual(4, t3.BuildStart);
            Assert.AreEqual(6, t3.BuildFinish);

            manager.DeleteAction(t2);

            Assert.AreEqual(3, t3.BuildStart);
            Assert.AreEqual(5, t3.BuildFinish);
        }
コード例 #10
0
        public void TestMoveRight()
        {
            var g1 = new KAction()
            {
                Label = "G1", WBS = "1"
            };
            var t1 = new KAction()
            {
                Label = "T1", WBS = "1.1"
            };
            var t11 = new KAction()
            {
                Label = "T11", WBS = "1.1.1"
            };
            var t2 = new KAction()
            {
                Label = "T2", WBS = "1.2"
            };
            var t3 = new KAction()
            {
                Label = "T3", WBS = "1.3"
            };
            var t4 = new KAction()
            {
                Label = "T4", WBS = "1.4"
            };
            var xcvb = new KAction()
            {
                Label = "xcvb", WBS = "2"
            };
            var xbc = new KAction()
            {
                Label = "xbc", WBS = "3"
            };
            var vcxbv = new KAction()
            {
                Label = "vcxbv", WBS = "3.1"
            };

            var actions = new List <KAction>()
            {
                g1, t1, t11, t2, t3, t4, xcvb, xbc, vcxbv
            };

            var collection = new BulkObservableCollection <DataTreeGridItem>();

            var manager = new GridActionsManager(collection, null, null);

            manager.ChangeView(GanttGridView.WBS, null);

            manager.RegisterInitialActions(actions);

            manager.MoveRight((ActionGridItem)collection[3]);

            AssertWBS(g1, "1");
            AssertWBS(t1, "1.1");
            AssertWBS(t11, "1.1.1");

            AssertWBS(t2, "1.1.2");
            AssertWBS(t3, "1.2");
            AssertWBS(t4, "1.3");
            AssertWBS(xcvb, "2");
            AssertWBS(xbc, "3");
            AssertWBS(vcxbv, "3.1");
        }