Пример #1
0
        public MgaFCO RunDesignExporter(string asmName)
        {
            MgaFCO componentAssembly;

            proj.BeginTransactionInNewTerr();
            string fileExtension = ".adp";

            try
            {
                componentAssembly = (MgaFCO)proj.RootFolder.GetObjectByPathDisp("/@" + FolderName + "/@" + asmName);
                if (componentAssembly.Meta.Name == "DesignContainer")
                {
                    fileExtension = ".adm";
                }
                Assert.NotNull(componentAssembly);
                var designExporter = new CyPhyDesignExporter.CyPhyDesignExporterInterpreter();
                designExporter.Initialize(proj);

                var parameters = new CyPhyGUIs.InterpreterMainParameters()
                {
                    CurrentFCO      = componentAssembly,
                    Project         = proj,
                    OutputDirectory = AdmPath
                };

                designExporter.MainInTransaction(parameters, true);
            }
            finally
            {
                proj.AbortTransaction();
            }

            Assert.True(File.Exists(Path.Combine(fixture.AdmPath, asmName + fileExtension)));
            return(componentAssembly);
        }
Пример #2
0
        public avm.Design Convert(String pathDE)
        {
            MgaObject objDE = null;

            proj.PerformInTransaction(delegate
            {
                objDE = proj.get_ObjectByPath(pathDE);
            });
            Assert.NotNull(objDE);

            var interp = new CyPhyDesignExporter.CyPhyDesignExporterInterpreter();

            interp.Initialize(proj);
            InterpreterMainParameters param = new InterpreterMainParameters()
            {
                OutputDirectory = PathTest,
                CurrentFCO      = objDE as MgaFCO,
                Project         = proj
            };
            var result = interp.Main(param);

            Assert.True(result.Success);

            // Load the new .adm file
            var pathAdm = Path.Combine(PathTest,
                                       pathDE.Split('/').Last() + ".adm");
            var xml    = File.ReadAllText(pathAdm);
            var design = OpenMETA.Interchange.AvmXmlSerializer.Deserialize <avm.Design>(xml);

            Assert.NotNull(design);

            return(design);
        }
Пример #3
0
        private void ExportDesignPackage(String name)
        {
            // Get all designs in project
            var filter = proj.CreateFilter();

            filter.Kind = "ComponentAssembly";
            filter.Name = name;

            MgaFCOs assemblies = null;

            proj.PerformInTransaction(delegate
            {
                assemblies = proj.AllFCOs(filter);
            });

            Assert.NotNull(assemblies);
            Assert.Equal(1, assemblies.Count);

            var interp = new CyPhyDesignExporter.CyPhyDesignExporterInterpreter()
            {
                OutputDir = fixture.PathTest
            };

            foreach (var fco in assemblies)
            {
                proj.PerformInTransaction(delegate
                {
                    interp.Main(proj, fco as MgaFCO, null, 0);
                });
                interp.DisposeLogger();
            }
        }
Пример #4
0
        public void ExportAll()
        {
            String pathTest = Path.Combine(fixture.PathTest, "all");

            Directory.CreateDirectory(pathTest);

            var interp = new CyPhyDesignExporter.CyPhyDesignExporterInterpreter()
            {
                OutputDir = pathTest
            };

            proj.PerformInTransaction(delegate
            {
                interp.Main(proj, null, null, 0);
            });
            interp.DisposeLogger();

            // Make sure files exist
            var expected = new List <String>
            {
                "NestedFolders.adp",
                "NoArtifacts.adp",
                "OneArtifact.adp"
            };

            foreach (var path in expected)
            {
                var fullPath = Path.Combine(pathTest, path);
                Assert.True(File.Exists(fullPath));
            }
        }
        public avm.Design Convert(String pathDE)
        {
            MgaObject objDE = null;
            proj.PerformInTransaction(delegate
            {
                objDE = proj.get_ObjectByPath(pathDE);
            });
            Assert.NotNull(objDE);

            var interp = new CyPhyDesignExporter.CyPhyDesignExporterInterpreter();
            interp.Initialize(proj);
            InterpreterMainParameters param = new InterpreterMainParameters()
            {
                OutputDirectory = PathTest,
                CurrentFCO = objDE as MgaFCO,
                Project = proj
            };
            var result = interp.Main(param);
            Assert.True(result.Success);

            // Load the new .adm file
            var pathAdm = Path.Combine(PathTest,
                                       pathDE.Split('/').Last() + ".adm");
            var xml = File.ReadAllText(pathAdm);
            var design = XSD2CSharp.AvmXmlSerializer.Deserialize<avm.Design>(xml);
            Assert.NotNull(design);

            return design;
        }
Пример #6
0
        //[Fact]
        public void DesignSpaceWithRefs()
        {
            var fullTestPath       = Path.Combine(_exportModelDirectory, "DesignSpaceWithRefs");
            var xmeFilePath        = Path.Combine(fullTestPath, "DesignSpaceWithRefs.xme");
            var pathExportedDesign = Path.Combine(fullTestPath, "DesignSpace.adm");

            // delete design file if it already exists
            if (File.Exists(pathExportedDesign))
            {
                File.Delete(pathExportedDesign);
            }

            String connectionString;

            GME.MGA.MgaUtils.ImportXMEForTest(xmeFilePath, out connectionString);

            var  proj = new MgaProject();
            bool ro_mode;

            proj.Open(connectionString, out ro_mode);
            proj.EnableAutoAddOns(true);

            try
            {
                var designExporter = new CyPhyDesignExporter.CyPhyDesignExporterInterpreter();
                designExporter.Initialize(proj);

                var    mgaGateway = new MgaGateway(proj);
                MgaFCO currentFCO = null;
                mgaGateway.PerformInTransaction(delegate
                {
                    currentFCO = proj.get_ObjectByPath("/@DesignSpaces|kind=DesignSpace|relpos=0/@DesignSpace|kind=DesignContainer|relpos=0") as MgaFCO;
                    Assert.NotNull(currentFCO);
                });

                var parameters = new CyPhyGUIs.InterpreterMainParameters()
                {
                    CurrentFCO      = currentFCO,
                    Project         = proj,
                    OutputDirectory = fullTestPath
                };

                var result = designExporter.Main(parameters);

                var design = avm.Design.LoadFromFile(pathExportedDesign);

                /// Add assert statements to check structure
                var root = design.RootContainer;
                Assert.NotNull(root);

                Assert.Equal(1, root.Container1.Count(c => c.Name == "AltContainer"));
                var AltContainer = root.Container1.First(c => c.Name == "AltContainer");

                Assert.Equal(1, AltContainer.ComponentInstance.Count(ci => ci.Name == "CompA_5"));
                Assert.Equal(1, AltContainer.ComponentInstance.Count(ci => ci.Name == "CompA_6"));
                Assert.Equal(1, AltContainer.ComponentInstance.Count(ci => ci.Name == "CompA_7"));

                Assert.Equal(1, root.Container1.Count(c => c.Name == "DesignContainer"));
                var DesignContainer = root.Container1.First(c => c.Name == "DesignContainer");

                Assert.Equal(1, DesignContainer.ComponentInstance.Count(ci => ci.Name == "CompA3"));

                Assert.Equal(1, DesignContainer.Container1.Count(c => c.Name == "Assembly1"));
                var Assembly1 = DesignContainer.Container1.First(c => c.Name == "Assembly1");

                Assert.Equal(1, Assembly1.ComponentInstance.Count(ci => ci.Name == "CompA1"));
                Assert.Equal(1, Assembly1.ComponentInstance.Count(ci => ci.Name == "CompA2"));

                Assert.Equal(1, root.Container1.Count(c => c.Name == "ReusableContainer"));
                var ReusableContainer = root.Container1.First(c => c.Name == "ReusableContainer");

                Assert.Equal(1, ReusableContainer.Container1.Count(c => c.Name == "Assembly4"));
                var Assembly4 = ReusableContainer.Container1.First(c => c.Name == "Assembly4");

                Assert.Equal(1, Assembly4.ComponentInstance.Count(ci => ci.Name == "CompA1"));
                Assert.Equal(1, Assembly4.ComponentInstance.Count(ci => ci.Name == "CompA2"));

                Assert.Equal(1, ReusableContainer.ComponentInstance.Count(ci => ci.Name == "CompA4"));

                Assert.Equal(1, root.ComponentInstance.Count(ci => ci.Name == "CompA"));

                Assert.Equal(1, root.ComponentInstance.Count(ci => ci.Name == "CompA"));
            }
            finally
            {
                proj.Close();
            }
        }
Пример #7
0
        //[Fact]
        public void DesignSpaceWithRefs()
        {
            var fullTestPath = Path.Combine(_exportModelDirectory, "DesignSpaceWithRefs");
            var xmeFilePath = Path.Combine(fullTestPath, "DesignSpaceWithRefs.xme");
            var pathExportedDesign = Path.Combine(fullTestPath, "DesignSpace.adm");

            // delete design file if it already exists
            if (File.Exists(pathExportedDesign))
            {
                File.Delete(pathExportedDesign);
            }

            String connectionString;
            GME.MGA.MgaUtils.ImportXMEForTest(xmeFilePath, out connectionString);

            var proj = new MgaProject();
            bool ro_mode;
            proj.Open(connectionString, out ro_mode);
            proj.EnableAutoAddOns(true);

            try
            {
                var designExporter = new CyPhyDesignExporter.CyPhyDesignExporterInterpreter();
                designExporter.Initialize(proj);

                var mgaGateway = new MgaGateway(proj);
                MgaFCO currentFCO = null;
                mgaGateway.PerformInTransaction(delegate
                {
                    currentFCO = proj.get_ObjectByPath("/@DesignSpaces|kind=DesignSpace|relpos=0/@DesignSpace|kind=DesignContainer|relpos=0") as MgaFCO;
                    Assert.NotNull(currentFCO);
                });

                var parameters = new CyPhyGUIs.InterpreterMainParameters()
                {
                    CurrentFCO = currentFCO,
                    Project = proj,
                    OutputDirectory = fullTestPath
                };

                var result = designExporter.Main(parameters);

                var design = avm.Design.LoadFromFile(pathExportedDesign);

                /// Add assert statements to check structure
                var root = design.RootContainer;
                Assert.NotNull(root);

                Assert.Equal(1, root.Container1.Count(c => c.Name == "AltContainer"));
                var AltContainer = root.Container1.First(c => c.Name == "AltContainer");

                Assert.Equal(1, AltContainer.ComponentInstance.Count(ci => ci.Name == "CompA_5"));
                Assert.Equal(1, AltContainer.ComponentInstance.Count(ci => ci.Name == "CompA_6"));
                Assert.Equal(1, AltContainer.ComponentInstance.Count(ci => ci.Name == "CompA_7"));

                Assert.Equal(1, root.Container1.Count(c => c.Name == "DesignContainer"));
                var DesignContainer = root.Container1.First(c => c.Name == "DesignContainer");

                Assert.Equal(1, DesignContainer.ComponentInstance.Count(ci => ci.Name == "CompA3"));

                Assert.Equal(1, DesignContainer.Container1.Count(c => c.Name == "Assembly1"));
                var Assembly1 = DesignContainer.Container1.First(c => c.Name == "Assembly1");

                Assert.Equal(1, Assembly1.ComponentInstance.Count(ci => ci.Name == "CompA1"));
                Assert.Equal(1, Assembly1.ComponentInstance.Count(ci => ci.Name == "CompA2"));

                Assert.Equal(1, root.Container1.Count(c => c.Name == "ReusableContainer"));
                var ReusableContainer = root.Container1.First(c => c.Name == "ReusableContainer");

                Assert.Equal(1, ReusableContainer.Container1.Count(c => c.Name == "Assembly4"));
                var Assembly4 = ReusableContainer.Container1.First(c => c.Name == "Assembly4");

                Assert.Equal(1, Assembly4.ComponentInstance.Count(ci => ci.Name == "CompA1"));
                Assert.Equal(1, Assembly4.ComponentInstance.Count(ci => ci.Name == "CompA2"));

                Assert.Equal(1, ReusableContainer.ComponentInstance.Count(ci => ci.Name == "CompA4"));

                Assert.Equal(1, root.ComponentInstance.Count(ci => ci.Name == "CompA"));

                Assert.Equal(1, root.ComponentInstance.Count(ci => ci.Name == "CompA"));
            }
            finally
            {
                proj.Close();
            }
        }