Exemple #1
0
        public IEnumerable <VisualHref> VisualHrefsOf(IStreamThing source)
        {
            source.DeCompress();

            IEnumerable <VisualHref> result = new VisualHref[0];
            var stream = source.Data;

            if (stream == null)
            {
                return(null);
            }
            try {
                stream.Position = 0;
                var graph = new VisualThingGraph()
                {
                    Source = ThingGraph
                };
                var serializer = new VisualThingXmlSerializer {
                    VisualThingGraph = graph, Layout = this.Layout
                };
                serializer.Read(stream);
                stream.Position = 0;

                result = serializer.VisualsCollection
                         .Where(v => !(v is IVisualEdge))
                         .Select(v => HrefOfVisual(graph, v))
                         .ToArray();
            } catch (Exception ex) {
                // TODO: stream-closed-error should never happen.Try to get reread the source
                Registry.Pooled <IExceptionHandler> ().Catch(ex, MessageType.OK);
            } finally {
                source.ClearRealSubject();
            }
            return(result);
        }
Exemple #2
0
        public void FoldingTest1()
        {
            var graph = new VisualThingGraph();

            var test = new EntityProgrammingSceneTest();

            test.Mock.SampleFactory.Graph = graph;
            test.Net();
        }
Exemple #3
0
        public void ThingGraphFactory()
        {
            var graph = new VisualThingGraph();

            var factory = new ThingEntityGraphFactory <ProgrammingLanguageFactory <IGraphEntity, IGraphEdge> > ();

            factory.Populate(graph.Source);
            Trace.Write(
                GraphTestUtils.ReportGraph <IThing, ILink> (graph.Source, factory.Name));
        }
Exemple #4
0
        public VisualHref HrefOfVisual(VisualThingGraph graph, IVisual v)
        {
            var t = graph.ThingOf(v);

            return(new VisualHref {
                Text = v.Data.ToString(),
                Id = t.Id.ToString("X16"),
                Location = v.Location,
                Size = v.Size
            });
        }
Exemple #5
0
        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);
            }
        }
        public void ProgramminglanguageJavaDeleteOverPair()
        {
            ReportDetail("ProgramminglanguageJavaDeleteOverPair");
            var dataSource = this.Graph;
            var factory    =
                new ThingEntityGraphFactory <EntityProgrammingLanguageFactory>();

            factory.Populate(dataSource);

            var java                 = new TestItem(factory.Nodes[3].Id, null, null, null); // Java
            var programming          = new TestItem(factory.Nodes[1].Id, null, null, null); // Programming
            var programming2Language = new TestItem(factory.Edges[1].Id, null, null, null); // Programming->Language

            this.Close();
            dataSource = this.Graph;

            java.thing                 = dataSource.GetById(java.id);
            programming.thing          = dataSource.GetById(programming.id);
            programming2Language.thing = dataSource.GetById(programming2Language.id);

            var pairOne = new VisualThingGraph(new VisualGraph(), dataSource);

            programming.one = pairOne.Get(programming.thing);

            Expand <IVisual, IVisualEdge>(pairOne, programming.one);
            var pairOneTwigs    = pairOne.Twig(java.one);
            var dataSourceTwigs = dataSource.Twig(java.thing);

            java.one = pairOne.Get(java.thing);
            programming2Language.one = pairOne.Get(programming2Language.thing);

            Remove <IVisual, IVisualEdge>(pairOne, java.one);

            IsRemoved <IVisual, IVisualEdge>(pairOne, programming.one, java.one);
            IsRemoved <IVisual, IVisualEdge>(pairOne, pairOneTwigs);
            IsRemoved <IVisual, IVisualEdge>(pairOne, pairOne.Twig(programming2Language.one), java.one);

            IsRemoved <IThing, ILink>(dataSource, programming.thing, java.thing);
            IsRemoved <IThing, ILink>(dataSource, dataSourceTwigs);
            IsRemoved <IThing, ILink>(dataSource, dataSource.Twig(programming2Language.thing), java.thing);
        }
Exemple #7
0
        public static VisualThingGraph GetSourceGraph <TFactory> (int count)
            where TFactory : ISampleGraphFactory <IGraphEntity, IGraphEdge>, new ()
        {
            var mock = new SceneTestEnvironment <IGraphEntity, IGraphEdge, ProgrammingLanguageFactory <IGraphEntity, IGraphEdge> > ();

            mock.SampleFactory.Count = count;

            mock.Display.Reset();
            mock.SceneFacade.ShowAllData();
            mock.Display.Perform();

            var visualGraph = (mock.Scene.Graph as SubGraph <IVisual, IVisualEdge>).Sink;

            visualGraph.ChangeData  = null;
            visualGraph.GraphChange = null;


            var sourceGraph = new VisualThingGraph(visualGraph, new ThingGraph());

            sourceGraph.Mapper.ConvertSinkSource();
            return(sourceGraph);
        }
Exemple #8
0
        public void FoldingExpandTest()
        {
            var graph = new VisualThingGraph();

            var test = new EntityProgrammingSceneTest();

            test.Mock.SampleFactory.Graph = graph;
            test.Mock.Scene       = new Scene();
            test.Mock.Scene.Graph = graph;

            var factory = new ThingEntityGraphFactory <ProgrammingLanguageFactory <IGraphEntity, IGraphEdge> > ();

            factory.Count = 10;
            factory.Populate(graph.Source);

            test.Mock.SetFocused(graph.Get(factory.Nodes[1]));
            Trace.Write(
                GraphTestUtils.ReportGraph <IVisual, IVisualEdge> (graph.Sink, factory.Name));

            test.Mock.SceneFacade.Expand(false);

            Trace.Write(
                GraphTestUtils.ReportGraph <IVisual, IVisualEdge> (graph.Sink, factory.Name));
        }
        public void ProgramminglanguageJavaDeleteTestPingBack()
        {
            ReportDetail("ProgramminglanguageJavaDeleteTestPingBack");
            var dataSource = this.Graph;

            var factory =
                new ThingEntityGraphFactory <EntityProgrammingLanguageFactory> ();

            factory.Populate(dataSource);

            var java                 = new TestItem(factory.Nodes[3].Id, null, null, null); // Java
            var list                 = new TestItem(factory.Nodes[7].Id, null, null, null); // List
            var programming          = new TestItem(factory.Nodes[1].Id, null, null, null); // Programming
            var programming2Language = new TestItem(factory.Edges[1].Id, null, null, null); // Programming->Language


            this.Close();
            dataSource = this.Graph;

            java.thing = dataSource.GetById(java.id);
            list.thing = dataSource.GetById(list.id);
            programming2Language.thing = dataSource.GetById(programming2Language.id);
            programming.thing          = dataSource.GetById(programming.id);

            var pairOne = new VisualThingGraph(new VisualGraph(), dataSource);

            var viewOne = new SubGraph <IVisual, IVisualEdge>(pairOne, new VisualGraph());

            programming.one = pairOne.Get(programming.thing); // Programming

            // expand viewOne:
            foreach (var item in pairOne.Walk().DeepWalk(programming.one, 0))
            {
                viewOne.Sink.Add(item.Node);
            }

            var pairOneTwigs    = pairOne.Twig(java.one);
            var dataSourceTwigs = dataSource.Twig(java.thing);

            var pairTwo = new VisualThingGraph(new VisualGraph(), dataSource);

            var viewTwo = new SubGraph <IVisual, IVisualEdge>(pairTwo, new VisualGraph());

            java.one        = pairOne.Get(java.thing);
            java.two        = pairTwo.Get(java.thing);
            programming.two = pairTwo.Get(programming.thing);

            // delete over PingBack in both views:


            var deleteCollection = new List <IVisualEdge>(viewOne.PostorderTwig(java.one));

            foreach (var linkOne in deleteCollection)  // Java
            {
                var linkTwo = viewOne.LookUp <IVisual, IVisualEdge, IThing, ILink>(viewTwo, linkOne);
                viewTwo.Remove(linkTwo);
                viewOne.Remove(linkOne);
            }

            java.two = viewOne.LookUp <IVisual, IVisualEdge, IThing, ILink>(viewTwo, java.one);
            viewTwo.Remove(java.two);
            viewOne.Remove(java.one);

            // testing the dataSource:
            IsRemoved <IThing, ILink>(dataSource, programming.thing, java.thing);

            var edges = dataSource.Edges(programming2Language.thing);

            foreach (var link in edges)
            {
                Assert.AreNotEqual(link.Root, java.thing);
                Assert.AreNotEqual(link.Leaf, java.thing);
            }

            IsRemoved <IThing, ILink>(dataSource, dataSourceTwigs);

            // testing pairOne
            IsRemoved <IVisual, IVisualEdge>(pairOne, programming.one, java.one);
            IsRemoved <IVisual, IVisualEdge>(pairOne, pairOneTwigs);

            // testing pairTwo
            IsRemoved <IVisual, IVisualEdge>(pairTwo, programming.two, java.two);
        }