Exemple #1
0
        public void TestLoadCompositeComponents()
        {
            Library.Clear();
            Assert.AreEqual(0, Library.Components.Count());

            //set library components to new directory
            string testComponentsPath = System.IO.Path.Combine(AppContext.BaseTestDirectory, "TestLoadCompositeComponents");

            AppContext.Settings.ComponentPaths.Clear();
            AppContext.Settings.ComponentPaths.Add(new SettingsPath(true, testComponentsPath));

            string outputAssemblyPath = System.IO.Path.Combine(testComponentsPath, "MockComponents.dll");

            //compile Mock Components to the test directory
            TraceLabTestApplication.CompileMockComponents(outputAssemblyPath);

            //try to load
            var libraryAccessor = new ComponentsLibrary_Accessor(new PrivateObject(Library));

            libraryAccessor.LoadComponentsDefinitions(AppContext.WorkspaceInstance.TypeDirectories);

            //if successful there should be two composite components loaded in the library
            int counter = 0;

            foreach (MetadataDefinition definition in Library.Components)
            {
                CompositeComponentMetadataDefinition compositeCompDefinition = definition as CompositeComponentMetadataDefinition;
                if (compositeCompDefinition != null)
                {
                    //assert its graph is not empty
                    Assert.IsNotNull(compositeCompDefinition.ComponentGraph);
                    counter++;
                }
            }

            Assert.AreEqual(10, counter);
            Assert.AreEqual(15, Library.Components.Count()); //10 composite components + 5 primitive components from MockComponents.dll

            Library.Clear();
        }