Ejemplo n.º 1
0
        public void DefineCompositeComponentBasicTestSelectSubraphWithNoEndAndStart()
        {
            // load the experiment to be exported
            string     experimentFilename = System.IO.Path.Combine(AppContext.BaseTestDirectory, "experiment_define_composite_component_basic_test.teml");
            Experiment experiment         = ExperimentManager.Load(experimentFilename, AppContext.Components);

            experiment.Settings = AppContext.Settings; //assure that we apply global settings

            //select just one node
            foreach (ExperimentNode node in experiment.Vertices)
            {
                if (node.ID == TestImporterID)
                {
                    node.IsSelected = true;
                }
            }

            DefiningCompositeComponentSetup setup = new DefiningCompositeComponentSetup(experiment);

            Assert.IsNotNull(setup);

            Assert.AreEqual(1, setup.InputSettings.Count);
            Assert.AreEqual(1, setup.OutputSettings.Count);
            Assert.AreEqual(0, setup.ConfigSettings.Count);
            Assert.IsTrue(setup.InputSettings["test1"].Include);
            Assert.IsTrue(setup.OutputSettings["test2"].Include);

            //rescan library to be sure it is fresh scan
            int numberOfComponentsInLibrary = GetCountOfComponentsInLibrary();

            //let's export the experiment as composite component
            setup.CompositeComponentLocationFilePath = exportFile;

            Assert.IsFalse(File.Exists(exportFile));
            setup.DefineComponent();

            Assert.IsTrue(File.Exists(exportFile));

            int updatedNumberOfComponents = GetCountOfComponentsInLibrary();

            //after rescan there should be one more component in the library
            Assert.AreEqual(numberOfComponentsInLibrary + 1, updatedNumberOfComponents);

            //iterate through all components until find new composite component
            CompositeComponentMetadataDefinition compositeComponentDefinition = FindCompositeComponent(exportFile);

            //assure that composite component definition has been found
            Assert.IsNotNull(compositeComponentDefinition); //if fails, composite component has not been found

            Assert.AreEqual(setup.Name, compositeComponentDefinition.Label);
            Assert.AreEqual(setup.Description, compositeComponentDefinition.Description);
            Assert.AreEqual(setup.Author, compositeComponentDefinition.Author);
            Assert.IsNotNull(compositeComponentDefinition.ComponentGraph);

            //the number of configuration properties should be the same
            Assert.AreEqual(setup.ConfigSettings.Count, compositeComponentDefinition.ConfigurationWrapperDefinition.Properties.Count);

            Assert.AreEqual(1, compositeComponentDefinition.IOSpecDefinition.Input.Count);  //one input was included
            Assert.AreEqual(1, compositeComponentDefinition.IOSpecDefinition.Output.Count); //one output was included
        }
Ejemplo n.º 2
0
        public void DefineCompositeComponentBasicTestSelectAllNodes()
        {
            // load the experiment to be exported
            string     experimentFilename = System.IO.Path.Combine(AppContext.BaseTestDirectory, "experiment_define_composite_component_basic_test.teml");
            Experiment experiment         = ExperimentManager.Load(experimentFilename, AppContext.Components);

            experiment.Settings = AppContext.Settings; //assure that we apply global settings

            //in first basic test select all nodes
            foreach (ExperimentNode node in experiment.Vertices)
            {
                node.IsSelected = true;
            }

            DefiningCompositeComponentSetup setup = new DefiningCompositeComponentSetup(experiment);

            Assert.IsNotNull(setup);

            Assert.AreEqual(1, setup.InputSettings.Count);
            Assert.AreEqual(2, setup.OutputSettings.Count);
            Assert.AreEqual(1, setup.ConfigSettings.Count);

            Assert.IsTrue(setup.InputSettings["test1"].Include);
            Assert.IsTrue(setup.OutputSettings["test1"].Include);
            Assert.IsTrue(setup.OutputSettings["test2"].Include);

            //note, if there are two components with the same label and same config name, the expected behaviour is to add
            Assert.IsTrue(setup.ConfigSettings["Test writer Value"].Include);

            //get real names of the config values
            string configName1 = setup.ConfigSettings["Test writer Value"].PropertyObject.Name;

            //change settings to sth different values
            setup.Name        = "Test Composite Component";
            setup.Author      = "Author XYZ";
            setup.Description = "Composite Component to test export";

            //don't include following in the export
            setup.InputSettings["test1"].Include  = false;
            setup.OutputSettings["test1"].Include = false;

            //rescan library to be sure it is fresh scan
            int numberOfComponentsInLibrary = GetCountOfComponentsInLibrary();

            //set file path to composite component
            setup.CompositeComponentLocationFilePath = exportFile;
            Assert.IsFalse(File.Exists(setup.CompositeComponentLocationFilePath));

            setup.DefineComponent();

            Assert.IsTrue(File.Exists(exportFile));

            //rescan the library
            int updatedNumberOfComponents = GetCountOfComponentsInLibrary();

            //after rescan there should be one more component in the library
            Assert.AreEqual(numberOfComponentsInLibrary + 1, updatedNumberOfComponents);

            //iterate through all components until find new composite component
            CompositeComponentMetadataDefinition compositeComponentDefinition = FindCompositeComponent(exportFile);

            //assure that composite component definition has been found
            Assert.IsNotNull(compositeComponentDefinition); //if fails, composite component has not been found

            Assert.AreEqual(setup.Name, compositeComponentDefinition.Label);
            Assert.AreEqual(setup.Description, compositeComponentDefinition.Description);
            Assert.AreEqual(setup.Author, compositeComponentDefinition.Author);
            Assert.IsNotNull(compositeComponentDefinition.ComponentGraph);

            //the number of configuration properties should be the same
            Assert.AreEqual(setup.ConfigSettings.Count, compositeComponentDefinition.ConfigurationWrapperDefinition.Properties.Count);

            ConfigPropertyObject config1 = compositeComponentDefinition.ConfigurationWrapperDefinition.Properties[configName1];

            Assert.AreEqual("Test writer Value", config1.DisplayName);

            Assert.IsTrue(config1.Visible);                                                 //config1 should  be visible, because Include was set to false

            Assert.AreEqual(0, compositeComponentDefinition.IOSpecDefinition.Input.Count);  //no input was included
            Assert.AreEqual(1, compositeComponentDefinition.IOSpecDefinition.Output.Count); //only one output was included
        }
Ejemplo n.º 3
0
        public void DefineCompositeComponentFromExperimentWithAnotherCompositeComponentTest()
        {
            // load the experiment to be exported
            string     experimentFilename = System.IO.Path.Combine(AppContext.BaseTestDirectory, "experiment_with_composite_component.teml");
            Experiment experiment         = ExperimentManager.Load(experimentFilename, AppContext.Components);

            experiment.Settings = AppContext.Settings; //applying these settings was causing the bug #74

            //select all nodes
            foreach (ExperimentNode node in experiment.Vertices)
            {
                node.IsSelected = true;
            }

            DefiningCompositeComponentSetup setup = new DefiningCompositeComponentSetup(experiment);

            Assert.IsNotNull(experiment);
            Assert.AreEqual(3, experiment.VertexCount);
            Assert.IsNotNull(setup);

            Assert.AreEqual(0, setup.InputSettings.Count);
            Assert.AreEqual(2, setup.OutputSettings.Count);
            Assert.AreEqual(2, setup.ConfigSettings.Count);

            //check if default name is the same as experiment info
            Assert.IsTrue(setup.OutputSettings["test_x"].Include);
            Assert.IsTrue(setup.OutputSettings["test_y"].Include);
            Assert.IsTrue(setup.ConfigSettings["Composite Component Test writer Value"].Include);
            Assert.IsTrue(setup.ConfigSettings["Composite Component Test writer Value 2"].Include);

            //get real names of the config values
            string configName1 = setup.ConfigSettings["Composite Component Test writer Value"].PropertyObject.Name;
            string configName2 = setup.ConfigSettings["Composite Component Test writer Value 2"].PropertyObject.Name;

            //change settings to sth different values
            setup.Name        = "Complex Composite Component";
            setup.Author      = "Author XYZ";
            setup.Description = "Complex Composite Component to test export";

            //don't include following in the export
            setup.OutputSettings["test_y"].Include = false;

            //change alias
            setup.ConfigSettings["Composite Component Test writer Value"].Alias     = "Config 1";
            setup.ConfigSettings["Composite Component Test writer Value 2"].Alias   = "Config 2";
            setup.ConfigSettings["Composite Component Test writer Value 2"].Include = false;

            //rescan library to be sure it is fresh scan
            int numberOfComponentsInLibrary = GetCountOfComponentsInLibrary();

            //let's export the experiment as composite component
            Assert.IsFalse(File.Exists(exportFile));
            setup.CompositeComponentLocationFilePath = exportFile;

            setup.DefineComponent();

            Assert.IsTrue(File.Exists(exportFile));

            //rescan the library
            int updatedNumberOfComponents = GetCountOfComponentsInLibrary();

            //after rescan there should be one more component in the library
            Assert.AreEqual(numberOfComponentsInLibrary + 1, updatedNumberOfComponents);

            //iterate through all components until find new composite component
            CompositeComponentMetadataDefinition compositeComponentDefinition = FindCompositeComponent(exportFile);

            //assure that composite component definition has been found
            Assert.IsNotNull(compositeComponentDefinition); //if fails, composite component has not been found

            Assert.AreEqual(setup.Name, compositeComponentDefinition.Label);
            Assert.AreEqual(setup.Description, compositeComponentDefinition.Description);
            Assert.AreEqual(setup.Author, compositeComponentDefinition.Author);
            Assert.IsNotNull(compositeComponentDefinition.ComponentGraph);

            //the number of configuration properties should be the same
            Assert.AreEqual(setup.ConfigSettings.Count, compositeComponentDefinition.ConfigurationWrapperDefinition.Properties.Count);

            ConfigPropertyObject config1 = compositeComponentDefinition.ConfigurationWrapperDefinition.Properties[configName1];
            ConfigPropertyObject config2 = compositeComponentDefinition.ConfigurationWrapperDefinition.Properties[configName2];

            Assert.AreEqual("Config 1", config1.DisplayName);
            Assert.AreEqual("Config 2", config2.DisplayName);

            Assert.IsTrue(config1.Visible);
            Assert.IsFalse(config2.Visible);                                                //config1 should not be visible, because Include was set to false

            Assert.AreEqual(0, compositeComponentDefinition.IOSpecDefinition.Input.Count);  //none input value were included
            Assert.AreEqual(1, compositeComponentDefinition.IOSpecDefinition.Output.Count); //one output value was included
        }