public void PlaybackSession(string filename)
        {
            CloseActiveProject();

            string absFilename = filename;

            if (!FileHelper.IsAbsolute(absFilename))
            {
                absFilename = Path.Combine(TestDataDir, filename);
            }

            string        projDir = EditorProject.FindProjectFor(absFilename);
            EditorProject proj    = new EditorProject();

            if (projDir == null || !proj.Load(projDir))
            {
                throw new FileNotFoundException("Project file not found for " + absFilename);
            }

            EditorManager.Project = proj;

            RecordSession session = RecordSession.LoadFromFile(proj.MakeRelative(absFilename));

            if (session == null)
            {
                throw new FileNotFoundException("Session file not found", absFilename);
            }

            TestRecordReport report = new TestRecordReport();

            if (!session.Playback(report, true))
            {
                throw new Exception("Record session '" + session.Filename + "' failed.\nItem '" + report.CurrentItem + "' triggered the following error:\n\n" + report.LastError + "\n\n" + report.LastErrorDetailed);
            }
        }
        public void TestShapeSerialization()
        {
            const string TEST_SCENENAME = "TestShapeSerialization.scene";

            // setup new test project/scene
            TestManager.Helpers.CreateTestScene(TEST_SCENENAME);
            EditorProject project = EditorApp.Project;

            try
            {
                // create all registered shapes
                foreach (IShapeCreatorPlugin plugin in EditorManager.ShapeCreatorPlugins)
                {
                    plugin.ExecutePlugin();
                }
                string projectFile      = project.PathName;
                int    numCreatedShapes = CountShapeInstances(project.Scene);

                // cause engine view to refresh (to see that rendering the shapes doesn't cause a crash)
                TestManager.Helpers.ProcessEvents();

                // close map
                project.Save();

                ShapeCollection c1 = project.Scene.ActiveLayer.Root.ChildCollection;

                EditorManager.Scene.Close();
                project.Close();

                // reload map
                project = EditorManager.ProjectFactory.CreateInstance(null) as EditorProject;
                Assert.IsNotNull(project);

                project.Load(projectFile);
                EditorManager.Project = project;
                bool bResult = project.OpenScene(TEST_SCENENAME);
                Assert.IsTrue(bResult);

                // verify that shape instances exist
                int             numLoadedShapes = CountShapeInstances(project.Scene);
                ShapeCollection c2 = project.Scene.ActiveLayer.Root.ChildCollection;

                for (int i = 0; i < c1.Count; i++)
                {
                    ShapeBase s1 = c1[i];
                    ShapeBase s2 = c2[i];
                    Assert.AreEqual(s1.GetType(), s2.GetType());
                }

                Assert.AreEqual(numCreatedShapes, numLoadedShapes);

                TestManager.Helpers.CloseTestProject();
            }
            catch (Exception ex)
            {
                EditorManager.DumpException(ex, true);
            }
        }
        public void TestEntityPropertySerialization()
        {
            try
            {
                const string TEST_SCENENAME = "TestEntityPropertySerialization";

                // setup new test project/scene
                TestManager.Helpers.CreateTestScene(TEST_SCENENAME);
                EditorProject project = EditorApp.Project;

                // create an entity shape
                EditorManager.GetShapeCreatorPluginByName("Entity").ExecutePlugin();
                ShapeBase entityShape = EditorManager.Scene.ActiveLayer.Root.ChildCollection[0];

                string projectFile      = project.PathName;
                int    numCreatedShapes = CountShapeInstances(project.Scene);

                // cause engine view to refresh (to see that rendering the shapes doesn't cause a crash)
                TestManager.Helpers.ProcessEvents();

                // close map
                project.Save();
                project.Close();

                // reload map
                project = EditorManager.ProjectFactory.CreateInstance(null) as EditorProject;
                Assert.IsNotNull(project);
                project.Load(projectFile);
                EditorManager.Project = project;
                bool bResult = project.OpenScene(TEST_SCENENAME);
                Assert.IsTrue(bResult);

                // verify that EntityProperty type is part of the active EntityClassManager assembly
                entityShape = EditorManager.Scene.ActiveLayer.Root.ChildCollection[0];
                DynamicPropertyCollection entityProperties = (DynamicPropertyCollection)entityShape.GetType().InvokeMember("EntityProperties", BindingFlags.GetProperty, null, entityShape, new object[] {});
                Assert.IsTrue(EditorManager.EngineManager.EntityClassManager.Exists(entityProperties.CollectionType.UniqueName));

                TestManager.Helpers.CloseTestProject();
            }
            catch (Exception ex)
            {
                EditorManager.DumpException(ex, true);
                throw ex;
            }
        }
Exemplo n.º 4
0
        public void PlaybackSessionsInProject(string projectDir, string subdir)
        {
            CloseActiveProject();

            string absFilename = projectDir;

            if (!FileHelper.IsAbsolute(absFilename))
            {
                absFilename = Path.Combine(TestDataDir, projectDir);
            }

            string        projDir = EditorProject.FindProjectFor(Path.Combine(absFilename, "dummy.xyz"));
            EditorProject proj    = new EditorProject();

            if (projDir == null)
            {
                throw new FileNotFoundException("Project file not found for " + absFilename);
            }

            proj.Load(projDir);

            EditorManager.Project = proj;

            DirectoryInfo folder = new DirectoryInfo(proj.MakeAbsolute(subdir));

            FileInfo[] files = folder.GetFiles("*.record");
            foreach (FileInfo file in files)
            {
                RecordSession session = RecordSession.LoadFromFile(Path.Combine(subdir, file.Name));
                if (session == null)
                {
                    throw new FileNotFoundException("Session file not found", absFilename);
                }

                TestRecordReport report = new TestRecordReport();
                if (!session.Playback(report, true))
                {
                    throw new Exception("Record session '" + session.Filename + "' failed.\nItem '" + report.CurrentItem + "' triggered the following error:\n\n" + report.LastError + "\n\n" + report.LastErrorDetailed);
                }
            }
        }
Exemplo n.º 5
0
        public void PlaybackSessionsInProject(string projectDir, string subdir)
        {
            CloseActiveProject();

              string absFilename = projectDir;
              if (!FileHelper.IsAbsolute(absFilename))
            absFilename = Path.Combine(TestDataDir, projectDir);

              string projDir = EditorProject.FindProjectFor(Path.Combine(absFilename, "dummy.xyz"));
              EditorProject proj = new EditorProject();
              if (projDir == null || !proj.Load(projDir))
            throw new FileNotFoundException("Project file not found for " + absFilename);

              EditorManager.Project = proj;

              DirectoryInfo folder = new DirectoryInfo(proj.MakeAbsolute(subdir));
              FileInfo[] files = folder.GetFiles("*.record");
              foreach (FileInfo file in files)
              {
            RecordSession session = RecordSession.LoadFromFile(Path.Combine(subdir, file.Name));
            if (session == null)
              throw new FileNotFoundException("Session file not found", absFilename);

            TestRecordReport report = new TestRecordReport();
            if (!session.Playback(report, true))
              throw new Exception("Record session '" + session.Filename + "' failed.\nItem '" + report.CurrentItem + "' triggered the following error:\n\n" + report.LastError + "\n\n" + report.LastErrorDetailed);
              }
        }
Exemplo n.º 6
0
        public void PlaybackSession(string filename)
        {
            CloseActiveProject();

              string absFilename = filename;
              if (!FileHelper.IsAbsolute(absFilename))
            absFilename = Path.Combine(TestDataDir, filename);

              string projDir = EditorProject.FindProjectFor(absFilename);
              EditorProject proj = new EditorProject();
              if (projDir == null || !proj.Load(projDir))
            throw new FileNotFoundException("Project file not found for " + absFilename);

              EditorManager.Project = proj;

              RecordSession session = RecordSession.LoadFromFile(proj.MakeRelative(absFilename));
              if (session == null)
            throw new FileNotFoundException("Session file not found", absFilename);

              TestRecordReport report = new TestRecordReport();
              if (!session.Playback(report, true))
            throw new Exception("Record session '" + session.Filename + "' failed.\nItem '" + report.CurrentItem + "' triggered the following error:\n\n" + report.LastError + "\n\n" + report.LastErrorDetailed);
        }