public void TestSheet() { var sourceGraph = ModelHelper.GetSourceGraph <ProgrammingLanguageFactory <IGraphEntity, IGraphEdge> > (); var scene = new Scene(); scene.Graph = sourceGraph; var thingGraph = sourceGraph.Source as IThingGraph; var layout = this.CreateLayout(); layout.DataHandler = () => scene; new GraphSceneFacade <IVisual, IVisualEdge> (() => scene, layout) .Add(scene.Graph, true, false); var s = SaveSheet(scene, layout); var reader = new StreamReader(s); ReportDetail(reader.ReadToEnd()); s.Position = 0; var newScene = new Scene(); var sheet = new SheetSerializer(); var targetGraph = new VisualThingGraph(new VisualGraph(), thingGraph); newScene.Graph = targetGraph; s.Position = 0; sheet.Read(s, newScene.Graph, newScene.CloneLayout(layout)); foreach (var target in targetGraph) { var thing = targetGraph.Get(target); var source = sourceGraph.Get(thing); Assert.AreEqual(target.Location, source.Location); Assert.AreEqual(target.Size, source.Size); } foreach (var source in sourceGraph) { var thing = sourceGraph.Get(source); var target = targetGraph.Get(thing); Assert.AreEqual(target.Location, source.Location); Assert.AreEqual(target.Size, source.Size); } }
void TestScene(IGraphScene <IVisual, IVisualEdge> scene, IGraphSceneLayout <IVisual, IVisualEdge> layout, Stream s) { scene.CleanScene(); var sheet = new SheetSerializer(); s.Position = 0; sheet.Read(s, scene.Graph, scene.CloneLayout(layout)); var visualThingGraph = scene.Graph.Source <IVisual, IVisualEdge, IThing, ILink> (); foreach (var visual in scene.Elements) { var thing = visualThingGraph.Get(visual); Assert.IsNotNull(thing); } }