Exemple #1
0
        public void ImportCADZIP_Spring_Tungsten()
        {
            var zipPath = Path.Combine(testPath, "Spring_Tungsten.zip");

            // Import the ZIP file.
            // Check that we run without exception, have a manifest file,
            // have a folder for the component, and have 2 files in there.

            // Delete manifest and any subfolders
            File.Delete(manifestFilePath);
            if (Directory.Exists(Path.Combine(testPath, "components")))
            {
                Directory.Delete(Path.Combine(testPath, "components"), true);
            }

            var mgaProject = Common.GetProject(mgaPath);

            Assert.True(mgaProject != null, "Could not load MGA project.");

            var mgaGateway = new MgaGateway(mgaProject);

            mgaGateway.PerformInTransaction(delegate
            {
                var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                importer.Initialize(mgaProject);

                var result   = importer.ImportFile(mgaProject, testPath, zipPath);
                var tungsten = result.ChildObjects.Cast <IMgaFCO>().Where(x => x.Meta.Name == "Resource" && x.Name == "TUNGSTEN_SPRING.PRT").FirstOrDefault();
                Assert.Equal("CAD\\TUNGSTEN_SPRING.PRT", tungsten.StrAttrByName["Path"]);
            });
        }
Exemple #2
0
        public void ZipIsMissingACM()
        {
            var zipPath = Path.Combine(testPath, "TestModel_noACM.zip");

            var mgaProject = Common.GetProject(mgaPath);

            Assert.False(mgaProject == null, "Could not load MGA project.");

            var mgaGateway = new MgaGateway(mgaProject);

            mgaGateway.PerformInTransaction(delegate
            {
                var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                importer.Initialize(mgaProject);

                try
                {
                    var result = importer.ImportFile(mgaProject, testPath, zipPath);
                }
                finally
                {
                    importer.DisposeLogger();
                }
            });
        }
Exemple #3
0
        public void SetUnit()
        {
            File.Copy(orgXmePathInputModel, xmePathInputModel, true);

            String connString;

            MgaUtils.ImportXMEForTest(xmePathInputModel, out connString);
            var mgaPath = connString.Substring("MGA=".Length);

            Assert.True(File.Exists(mgaPath), "Input model not found; import may have failed.");

            var project = GetProject(mgaPath);

            var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();

            importer.Initialize(project);

            project.BeginTransactionInNewTerr();
            try
            {
                var fco = importer.ImportFile(project, testPath, acmPath);
                ISIS.GME.Dsml.CyPhyML.Interfaces.Component comp = ISIS.GME.Dsml.CyPhyML.Classes.Component.Cast(fco);

                var millimeter = comp.Children.PropertyCollection
                                 .First(p => p.Name.Equals("mm"))
                                 .Referred.unit;
                Assert.NotNull(millimeter);
                Assert.Equal("Millimeter", millimeter.Name);

                var henry = comp.Children.PropertyCollection
                            .First(p => p.Name.Equals("Henry"))
                            .Referred.unit;
                Assert.NotNull(henry);
                Assert.Equal("Henry", henry.Name);

                var acre = comp.Children.PropertyCollection
                           .First(p => p.Name.Equals("acre"))
                           .Referred.unit;
                Assert.NotNull(acre);
                Assert.Equal("Acre", acre.Name);
            }
            finally
            {
                project.CommitTransaction();
            }

            project.Save();
            project.Close();
        }
Exemple #4
0
        public static MgaFCO ImportComponentZip(MgaProject mgaProject, string zipPath)
        {
            try
            {
                CyPhyComponentImporter.CyPhyComponentImporterInterpreter importer =
                    new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();

                importer.Initialize(mgaProject);

                return(importer.ImportFile(mgaProject, Path.GetDirectoryName(mgaProject.ProjectConnStr.Substring("MGA=".Length)), Path.GetFullPath(zipPath)) as MgaFCO);
            }
            catch (Exception)
            {
                throw new VFDownloadFailedException();
            }
        }
Exemple #5
0
        public void ImportZIP()
        {
            var zipPath = Path.Combine(testPath, "TestModel.zip");

            // Import the ZIP file.
            // Check that we run without exception, have a manifest file,
            // have a folder for the component, and have 2 files in there.

            // Delete manifest and any subfolders
            File.Delete(manifestFilePath);
            if (Directory.Exists(Path.Combine(testPath, "components")))
            {
                Directory.Delete(Path.Combine(testPath, "components"), true);
            }

            var mgaProject = Common.GetProject(mgaPath);

            Assert.True(mgaProject != null, "Could not load MGA project.");

            bool resultIsNull = false;
            var  mgaGateway   = new MgaGateway(mgaProject);

            mgaGateway.PerformInTransaction(delegate
            {
                var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                importer.Initialize(mgaProject);

                try
                {
                    var result = importer.ImportFile(mgaProject, testPath, zipPath);
                    if (result == null)
                    {
                        resultIsNull = true;
                    }
                }
                finally
                {
                    importer.DisposeLogger();
                }
            });
            Assert.False(resultIsNull, "Exception occurred during import.");
            Assert.False(File.Exists(manifestFilePath), "Manifest erroneously generated");
        }
Exemple #6
0
        public void ProjectManifestPopulationTest()
        {
            var testPath = Path.Combine(Common._importModelDirectory, "ProjectManifestPopulation");
            var xmePath  = Path.Combine(testPath, "InputModel.xme");

            var pathGeneratedManifest = Path.Combine(testPath, "manifest.project.json");

            // Delete manifest, if it exists
            if (File.Exists(pathGeneratedManifest))
            {
                File.Delete(pathGeneratedManifest);
            }

            var mgaFilename = Path.ChangeExtension(xmePath, "mga");

            GME.MGA.MgaUtils.ImportXME(xmePath, mgaFilename);

            var mgaProject = Common.GetProject(mgaFilename);

            Assert.True(mgaProject != null, "Could not load MGA project.");

            AVM.DDP.MetaAvmProject proj = null;
            bool resultIsNull           = false;
            var  mgaGateway             = new MgaGateway(mgaProject);

            mgaGateway.PerformInTransaction(delegate {
                var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                importer.Initialize(mgaProject);

                var result = importer.ImportFile(mgaProject, testPath, Path.Combine(testPath, "InputModel.component.acm"));
                if (result == null)
                {
                    resultIsNull = true;
                }

                // Load manifest while we're in a transaction
                proj = AVM.DDP.MetaAvmProject.Create(mgaProject);
            });
            Assert.False(resultIsNull, "Exception occurred during import.");
            Assert.False(File.Exists(pathGeneratedManifest), "Manifest erroneously generated");
        }
Exemple #7
0
        public void ZipIsMissingResource()
        {
            var zipPath = Path.Combine(testPath, "TestModel_missingResource.zip");

            var mgaProject = Common.GetProject(mgaPath);

            Assert.False(mgaProject == null, "Could not load MGA project.");

            var mgaGateway = new MgaGateway(mgaProject);

            mgaGateway.PerformInTransaction(delegate
            {
                var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                importer.Initialize(mgaProject);

                Assert.DoesNotThrow(delegate
                {
                    var result = importer.ImportFile(mgaProject, testPath, zipPath);
                });
            });
        }
Exemple #8
0
        public static MgaFCO ImportComponentZip(MgaProject mgaProject, string zipPath)
        {
            try
            {
                CyPhyComponentImporter.CyPhyComponentImporterInterpreter importer =
                    new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();

                importer.Initialize(mgaProject);

                return importer.ImportFile(mgaProject, Path.GetDirectoryName(mgaProject.ProjectConnStr.Substring("MGA=".Length)), Path.GetFullPath(zipPath)) as MgaFCO;
            }
            catch (Exception)
            {
                throw new VFDownloadFailedException();
            }
        }
Exemple #9
0
        public void ProjectManifestPopulationTest()
        {
            var testPath = Path.Combine(Common._importModelDirectory, "ProjectManifestPopulation");
            var xmePath = Path.Combine(testPath, "InputModel.xme");

            var pathGeneratedManifest = Path.Combine(testPath, "manifest.project.json");
            // Delete manifest, if it exists
            if (File.Exists(pathGeneratedManifest))
                File.Delete(pathGeneratedManifest);

            var mgaFilename = Path.ChangeExtension(xmePath, "mga");
            GME.MGA.MgaUtils.ImportXME(xmePath, mgaFilename);

            var mgaProject = Common.GetProject( mgaFilename );
            Assert.True(mgaProject != null,"Could not load MGA project.");

            AVM.DDP.MetaAvmProject proj = null;
            bool resultIsNull = false;
            var mgaGateway = new MgaGateway(mgaProject);
            mgaProject.CreateTerritoryWithoutSink(out mgaGateway.territory);
            mgaGateway.PerformInTransaction(delegate {
                var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
                importer.Initialize(mgaProject);

                var result = importer.ImportFile(mgaProject,testPath,Path.Combine(testPath,"InputModel.component.acm"));
                if (result == null)
                    resultIsNull = true;

                // Load manifest while we're in a transaction
                proj = AVM.DDP.MetaAvmProject.Create(mgaProject);
            });
            Assert.False(resultIsNull,"Exception occurred during import.");
            Assert.False(File.Exists(pathGeneratedManifest), "Manifest erroneously generated");
        }
        public void SetUnit()
        {
            File.Copy(orgXmePathInputModel, xmePathInputModel, true);

            String connString;
            MgaUtils.ImportXMEForTest(xmePathInputModel, out connString);
            var mgaPath = connString.Substring("MGA=".Length);
            Assert.True(File.Exists(mgaPath), "Input model not found; import may have failed.");

            var project = GetProject(mgaPath);

            var importer = new CyPhyComponentImporter.CyPhyComponentImporterInterpreter();
            importer.Initialize(project);

            project.PerformInTransaction(delegate
            {
                var fco = importer.ImportFile(project, testPath, acmPath);
                ISIS.GME.Dsml.CyPhyML.Interfaces.Component comp = ISIS.GME.Dsml.CyPhyML.Classes.Component.Cast(fco);
                
                var millimeter = comp.Children.PropertyCollection
                                              .First(p => p.Name.Equals("mm"))
                                              .Referred.unit;
                Assert.NotNull(millimeter);
                Assert.Equal("Millimeter", millimeter.Name);

                var henry = comp.Children.PropertyCollection
                                         .First(p => p.Name.Equals("Henry"))
                                         .Referred.unit;
                Assert.NotNull(henry);
                Assert.Equal("Henry", henry.Name);

                var acre = comp.Children.PropertyCollection
                                        .First(p => p.Name.Equals("acre"))
                                        .Referred.unit;
                Assert.NotNull(acre);
                Assert.Equal("Acre", acre.Name);
            });

            project.Save();
            project.Close();
        }