Exemple #1
0
        public void TestUpdateGraphyAsyncTaskMerge()
        {
            // Verify a UpdateGraphAysncTask can't be merged with the other one
            // if they modifiy different nodes.
            OpenModel(TestDirectory + @"\core\scheduler\simple.dyn");

            var cbn = CurrentDynamoModel.CurrentWorkspace.Nodes.OfType<CodeBlockNodeModel>().FirstOrDefault();
            var funcNode = CurrentDynamoModel.CurrentWorkspace.Nodes.OfType<DSFunction>().FirstOrDefault();

            // Keep code block node be silent so that the graph won't be
            // executed automatically
            cbn.RaisesModificationEvents = false;

            var elementResolver = CurrentDynamoModel.CurrentWorkspace.ElementResolver;
            cbn.SetCodeContent("-22", elementResolver); // Invalid numeric value.
            cbn.MarkNodeAsModified();

            // Get a UpdateGrapyAsyncTask for the modification of cbn
            var scheduler = new DynamoScheduler(new SampleSchedulerThread(), true);
            UpdateGraphAsyncTask task1 = new UpdateGraphAsyncTask(scheduler, false);
            task1.Initialize(CurrentDynamoModel.EngineController, CurrentDynamoModel.CurrentWorkspace);

            // Get a UpdateGraphAsyncTask for the modification of Math.Sin()
            funcNode.MarkNodeAsModified();
            UpdateGraphAsyncTask task2 = new UpdateGraphAsyncTask(scheduler, false);
            task2.Initialize(CurrentDynamoModel.EngineController, CurrentDynamoModel.CurrentWorkspace);

            // And both async tasks should be kept.
            var mergeResult = task1.CanMergeWith(task2);
            Assert.AreEqual(AsyncTask.TaskMergeInstruction.KeepBoth, mergeResult);

            mergeResult = task2.CanMergeWith(task1);
            Assert.AreEqual(AsyncTask.TaskMergeInstruction.KeepBoth, mergeResult);

            scheduler.Shutdown();
        }
Exemple #2
0
        public void TestSchedulerCreationDestruction()
        {
            var schedulerThread = new SampleSchedulerThread();
            Assert.IsFalse(schedulerThread.Initialized);
            Assert.IsFalse(schedulerThread.Destroyed);

            var scheduler = new DynamoScheduler(schedulerThread, false);
            Assert.IsTrue(schedulerThread.Initialized);
            Assert.IsFalse(schedulerThread.Destroyed);

            scheduler.Shutdown();
            Assert.IsTrue(schedulerThread.Initialized);
            Assert.IsTrue(schedulerThread.Destroyed);
        }
        public void TestSchedulerCreationDestruction()
        {
            var schedulerThread = new SampleSchedulerThread();
            Assert.IsFalse(schedulerThread.Initialized);
            Assert.IsFalse(schedulerThread.Destroyed);

            var scheduler = new DynamoScheduler(schedulerThread, TaskProcessMode.Asynchronous);
            Assert.IsTrue(schedulerThread.Initialized);
            Assert.IsFalse(schedulerThread.Destroyed);

            scheduler.Shutdown();
            Assert.IsTrue(schedulerThread.Initialized);
            Assert.IsTrue(schedulerThread.Destroyed);
        }