Exemple #1
0
        public void ScopeWithCompositeComponent_ScopeNestedWorkspaceWrapperTearDownTest()
        {
            MockProgress progress = new MockProgress();

            string     testExperimentFilepath = System.IO.Path.Combine(AppContext.BaseTestDirectory, "Decision Scope with composite component.teml");
            Experiment experiment             = ExperimentManager.Load(testExperimentFilepath, AppContext.Components);

            using (var dispatcher = ExperimentRunnerHelper.CreateExperimentRunner(experiment, AppContext.WorkspaceInstance, AppContext.Components))
            {
                dispatcher.ExecuteExperiment(progress);
            }

            Assert.AreEqual(3, AppContext.WorkspaceInstance.Units.Count);

            HashSet <string> expectedUnitNames = new HashSet <string>();

            expectedUnitNames.Add("targetArtifacts");
            expectedUnitNames.Add("sourceArtifacts");
            expectedUnitNames.Add("similarityMatrix");

            foreach (WorkspaceUnit unit in AppContext.WorkspaceInstance.Units)
            {
                bool isCorrect = false;
                if (expectedUnitNames.Contains(unit.FriendlyUnitName))
                {
                    isCorrect = true;
                }
                Assert.IsTrue(isCorrect);
            }
        }
Exemple #2
0
        public void ScopeNestedWorkspaceWrapperTearDownTest()
        {
            MockProgress progress = new MockProgress();

            Experiment experiment = ExperimentManager.Load("DecisionScopeTest.teml", AppContext.Components);

            using (var dispatcher = ExperimentRunnerHelper.CreateExperimentRunner(experiment, AppContext.WorkspaceInstance, AppContext.Components))
            {
                dispatcher.ExecuteExperiment(progress);
            }

            Assert.AreEqual(2, AppContext.WorkspaceInstance.Units.Count);
            foreach (WorkspaceUnit unit in AppContext.WorkspaceInstance.Units)
            {
                bool isCorrect = false;
                if (unit.FriendlyUnitName.Equals("a") && (int)unit.Data == 1)
                {
                    isCorrect = true;
                }
                else if (unit.FriendlyUnitName.Equals("b") && (int)unit.Data == 7)
                {
                    isCorrect = true;
                }

                Assert.IsTrue(isCorrect);
            }
        }
Exemple #3
0
        public void PrepareAndRunBenchmarkExperiment()
        {
            Assert.Fail("Test temporarily broken. Ignored till contest feature is going to be revisited.");

            List <Benchmark> benchmarks    = BenchmarkLoader.LoadBenchmarksInfo(BenchmarkDirectory);
            Benchmark        testBenchmark = benchmarks[0];

            // load the experiment to be run against benchmark
            string     experimentFilename        = System.IO.Path.Combine(AppContext.BaseTestDirectory, "experiment_to_be_benchmarked.gml");
            Experiment experimentToBeBenchmarked = ExperimentManager.Load(experimentFilename, AppContext.Components);

            //prepare matching io
            testBenchmark.PrepareMatchingIOByType(experimentToBeBenchmarked);
            Assert.AreEqual(2, testBenchmark.BenchmarkInputSetting.Count);
            Assert.AreEqual(1, testBenchmark.BenchmarkOutputsSetting.Count);

            //match benchmarkSourceArtifact with original source artifacts
            foreach (BenchmarkItemSetting <IOItem> pair in testBenchmark.BenchmarkInputSetting)
            {
                IOItem item = pair.Item;
                ItemSettingCollection candidates = pair.CandidateSettings;
                if (item.MappedTo.Equals("benchmarkSourceArtifacts"))
                {
                    //we found the item we want to remap
                    pair.SelectedSetting = candidates["originalSourceArtifacts"];
                }
            }

            //finally prepare benchmark experiment
            testBenchmark.PrepareBenchmarkExperiment(experimentToBeBenchmarked, AppContext.Components);

            //assert that only two inputs are included in the export settings and one output
            int includedInputs = 0;

            foreach (KeyValuePair <string, ItemSetting> pair in testBenchmark.Setup.InputSettings)
            {
                if (pair.Value.Include == true)
                {
                    includedInputs++;
                }
            }
            Assert.AreEqual(2, includedInputs);

            int includedOutputs = 0;

            foreach (KeyValuePair <string, ItemSetting> pair in testBenchmark.Setup.OutputSettings)
            {
                if (pair.Value.Include == true)
                {
                    includedOutputs++;
                }
            }
            Assert.AreEqual(1, includedOutputs);

            Assert.IsNotNull(testBenchmark.BenchmarkExperiment);

            //for debug output file
            // string path = System.IO.Path.Combine(AppContext.BaseTestDirectory, "benchmarkTest1.gml");
            // AppContext.ExperimentManager.Save(testBenchmark.BenchmarkExperiment, path);

            MockProgress progress = new MockProgress();

            using (var dispatcher = ExperimentRunnerHelper.CreateExperimentRunner(testBenchmark.BenchmarkExperiment, AppContext.WorkspaceInstance, AppContext.Components))
            {
                dispatcher.ExecuteExperiment(progress);
                Assert.AreEqual(7, progress.NumSteps);
                Assert.IsFalse(progress.HasError);
            }
        }