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; } }