Beispiel #1
0
        public void TestTemplateGraphDisposal_InValidNodes()
        {
            IEditableExperiment experiment = ((IEditableExperiment)ExperimentManager.New());

            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            //construct some simple m_experiment
            ExperimentNode node1 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);
            ExperimentNode node2 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);
            ExperimentNode node3 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);

            node1.Data.Metadata.Label = "Broken Component";

            experiment.AddConnection(experiment.StartNode, node1);
            experiment.AddConnection(node1, node2);
            experiment.AddConnection(node2, node3);
            experiment.AddConnection(node3, experiment.EndNode);

            //initiate mockNodesFactory
            MockNodesFactory       mockNodesFactory = new MockNodesFactory();
            RunnableExperimentBase template         = GraphAdapter.Adapt(experiment, mockNodesFactory, AppContext.Components, AppContext.WorkspaceInstance.TypeDirectories);

            //adaptation should have failed and graph should be empty because broken node construction failed
            Assert.IsTrue(template.IsEmpty);

            //but also all of the previously created nodes before reaching the broken node during adaptation should have been disposed.
            foreach (MockNode node in mockNodesFactory.CreatedNodes)
            {
                Assert.IsTrue(node.disposed);
            }
        }
Beispiel #2
0
        public void TestTemplateGraphDisposal_ValidNodes()
        {
            IEditableExperiment experiment = ((IEditableExperiment)ExperimentManager.New());

            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            //construct some simple m_experiment
            ExperimentNode node1 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);
            ExperimentNode node2 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);

            experiment.AddConnection(experiment.StartNode, node1);
            experiment.AddConnection(node1, node2);
            experiment.AddConnection(node2, experiment.EndNode);

            //initiate mockNodesFactory
            MockNodesFactory       mockNodesFactory = new MockNodesFactory();
            RunnableExperimentBase template         = GraphAdapter.Adapt(experiment, mockNodesFactory, AppContext.Components, AppContext.WorkspaceInstance.TypeDirectories);

            foreach (MockNode node in mockNodesFactory.CreatedNodes)
            {
                Assert.IsFalse(node.disposed);
            }

            //execute disptacher, because in case of correct graph dispatcher disposes nodes
            MockProgress progress = new MockProgress();

            using (var dispatcher = ExperimentRunnerFactory.CreateExperimentRunner(template))
            {
                dispatcher.ExecuteExperiment(progress);
                Assert.IsFalse(progress.HasError);
            }

            foreach (MockNode node in mockNodesFactory.CreatedNodes)
            {
                Assert.IsTrue(node.disposed);
            }
        }
        public void TestTemplateGraphDisposal_InValidNodes()
        {
            IEditableExperiment experiment = ((IEditableExperiment)ExperimentManager.New());
            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            //construct some simple m_experiment
            ExperimentNode node1 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);
            ExperimentNode node2 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);
            ExperimentNode node3 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);

            node1.Data.Metadata.Label = "Broken Component";

            experiment.AddConnection(experiment.StartNode, node1);
            experiment.AddConnection(node1, node2);
            experiment.AddConnection(node2, node3);
            experiment.AddConnection(node3, experiment.EndNode);

            //initiate mockNodesFactory
            MockNodesFactory mockNodesFactory = new MockNodesFactory();
            RunnableExperimentBase template = GraphAdapter.Adapt(experiment, mockNodesFactory, AppContext.Components, AppContext.WorkspaceInstance.TypeDirectories);

            //adaptation should have failed and graph should be empty because broken node construction failed
            Assert.IsTrue(template.IsEmpty);

            //but also all of the previously created nodes before reaching the broken node during adaptation should have been disposed.
            foreach (MockNode node in mockNodesFactory.CreatedNodes)
            {
                Assert.IsTrue(node.disposed);
            }
        }
        public void TestTemplateGraphDisposal_ValidNodes()
        {
            IEditableExperiment experiment = ((IEditableExperiment)ExperimentManager.New());
            experiment.ExperimentInfo.FilePath = "C:\\somefakelocation\\mockExperiment.teml";
            //construct some simple m_experiment
            ExperimentNode node1 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);
            ExperimentNode node2 = experiment.AddComponentFromDefinition(m_emptyComponentMetaDefinition, 5, 5);

            experiment.AddConnection(experiment.StartNode, node1);
            experiment.AddConnection(node1, node2);
            experiment.AddConnection(node2, experiment.EndNode);

            //initiate mockNodesFactory
            MockNodesFactory mockNodesFactory = new MockNodesFactory();
            RunnableExperimentBase template = GraphAdapter.Adapt(experiment, mockNodesFactory, AppContext.Components, AppContext.WorkspaceInstance.TypeDirectories);

            foreach (MockNode node in mockNodesFactory.CreatedNodes)
            {
                Assert.IsFalse(node.disposed);
            }

            //execute disptacher, because in case of correct graph dispatcher disposes nodes
            MockProgress progress = new MockProgress();
            using (var dispatcher = ExperimentRunnerFactory.CreateExperimentRunner(template))
            {
                dispatcher.ExecuteExperiment(progress);
                Assert.IsFalse(progress.HasError);
            }

            foreach (MockNode node in mockNodesFactory.CreatedNodes)
            {
                Assert.IsTrue(node.disposed);
            }
        }