コード例 #1
0
        public void ThingIdSerializerTest()
        {
            IThingGraph graph = new ThingGraph();
            IThing      thing = factory.CreateItem();

            graph.Add(thing);
            graph.Add(factory.CreateItem());

            ThingXmlIdSerializer serializer = new ThingXmlIdSerializer();

            serializer.Graph  = graph;
            serializer.Things = graph;

            foreach (IThing t in graph)
            {
                Assert.IsTrue(serializer.Things.Contains(t));
            }

            Stream s = new MemoryStream();

            serializer.Write(s);
            s.Position = 0;

            serializer       = new ThingXmlIdSerializer();
            serializer.Graph = graph;
            serializer.Read(s);
            foreach (IThing t in graph)
            {
                Assert.IsTrue(serializer.Things.Contains(t));
            }
        }
コード例 #2
0
        public virtual void TestTitle()
        {
            this.ReportDetail("**** TestTitle");
            IThingGraph graph = new ThingGraph();
            IThing      thing = Factory.CreateItem();

            graph.Add(thing);

            IThing title   = Factory.CreateItem("Title1");
            var    digidoc = new DigidocSchema(graph, thing);

            // test the new description:
            digidoc.Title = title;
            ValidateTitle(digidoc, graph, thing, title);
            ValidateTitle(digidoc, graph, thing, title);

            // add same description again:
            digidoc.Title = title;
            ValidateTitle(digidoc, graph, thing, title);

            // the first description will be an orphan:
            IThing orphan = title;

            // make a new description:
            title         = Factory.CreateItem("Title2");
            digidoc.Title = title;
            ValidateTitle(digidoc, graph, thing, title);

            // test if orphan is deleted:
            Assert.IsFalse(graph.Contains(orphan), "Orphan not deleted");

            // take a new schema:
            digidoc = new DigidocSchema(graph, thing);
            ValidateTitle(digidoc, graph, thing, title);
        }
コード例 #3
0
        public virtual void TestDescription()
        {
            string testName = "TestDescription";

            this.ReportDetail(testName);
            IThingGraph graph = new ThingGraph();
            IThing      thing = Factory.CreateItem();

            graph.Add(thing);

            IThing       description = Factory.CreateItem("Description1");
            CommonSchema schema      = new CommonSchema(graph, thing);

            // test the new description:
            schema.Description = description;
            ValidateDescription(schema, graph, thing, description);
            ValidateDescription(schema, graph, thing, description);

            // add same description again:
            schema.Description = description;
            ValidateDescription(schema, graph, thing, description);

            // the first description will be an orphan:
            IThing orphan = description;

            // make a new description:
            description        = Factory.CreateItem("Description2");
            schema.Description = description;
            ValidateDescription(schema, graph, thing, description);

            // test if orphan is deleted:
            Assert.IsFalse(graph.Contains(orphan), "Orphan not deleted");

            // take a new schema:
            schema = new CommonSchema(graph, thing);
            ValidateDescription(schema, graph, thing, description);

            ReportSummary();
        }