示例#1
0
 public void FillTest()
 {
     string testpacfilename = "test.pxc";
     PxCell xCell = new PxCell(seqtriplets, testpacfilename, false);
     try
     {
         xCell.Fill(testdb);
         Assert.AreEqual(3, xCell.Root.Count());
         var e = (object[])xCell.Root.Element(2).Get().Value;
         Assert.AreEqual(e.Length, 2);
         Assert.AreEqual(e[0], 2);
         Assert.IsInstanceOfType(e[1], typeof(object[]));
         var o = (object[])e[1];
         Assert.AreEqual(o.Length, 4);
         Assert.AreEqual(o[0], "da");
         Assert.AreEqual(o[1], "db");
         Assert.AreEqual(o[2], "dc");
         Assert.AreEqual(o[3], "lang");
     }
     finally
     {
         xCell.Close();
     }
 }
        public void FillWholeVolumeSeqUnionTest()
        {
            var seqtriplets = new PTypeSequence(
                    new PTypeUnion(
                        new NamedType("op",
                            new PTypeRecord(
                                new NamedType("subject", new PType(PTypeEnumeration.sstring)),
                                new NamedType("char", new PType(PTypeEnumeration.character))
                            )),
                        new NamedType("dp",
                            new PTypeRecord(
                                new NamedType("subject", new PType(PTypeEnumeration.sstring)),
                                new NamedType("integer", new PType(PTypeEnumeration.integer)),
                                new NamedType("bool", new PType(PTypeEnumeration.boolean))
                            )
                        )
                    ));

            var testdb = new object[] {
                new object[] { 0, new object[] {"a", 'c'}},
                new object[] { 0, new object[] {"a1", 'c'}},
                new object[] { 1, new object[] {"da", 3, true}},
                new object[] { 0, new object[] {"a1", '1'}},
                new object[] { 1, new object[] {"da1", 7, true}},
                new object[] { 0, new object[] {"a2", '2'}},
                new object[] { 1, new object[] {"da2", 9, false}},
                new object[] { 1, new object[] {"da2", 11, true}},
                new object[] { 1, new object[] {"da3", 13, false}}
            };

            string testpacfilename = "test.pxc";
            PxCell xCell = new PxCell(seqtriplets, testpacfilename, false);

            xCell.Fill(testdb);

            CheckSequence(xCell);
        }
        public void FillWholeVolumeSeqRecordTest()
        {
            var seqtriplets = new PTypeSequence(new PType(PTypeEnumeration.integer));
            var testdb = new object[] { 1, 2, 3, 5, 15, 19, 21, 90 };

            string testpacfilename = "test.pxc";
            PxCell xCell = new PxCell(seqtriplets, testpacfilename, false);
            xCell.Fill(testdb);

            try
            {
                Assert.AreEqual(8, xCell.Root.Count());
                Assert.AreEqual(1, (int)xCell.Root.Element(0).Get().Value);
                Assert.AreEqual(3, (int)xCell.Root.Element(2).Get().Value);
                Assert.AreEqual(5, (int)xCell.Root.Element(3).Get().Value);
                Assert.AreEqual(15, (int)xCell.Root.Element(4).Get().Value);
                Assert.AreEqual(19, (int)xCell.Root.Element(5).Get().Value);
                Assert.AreEqual(90, (int)xCell.Root.Element(7).Get().Value);

                var objects = xCell.Root.Elements().Select(e => e.Get().Value).ToArray();
                Assert.AreEqual(1, (int)xCell.Root.Elements().ToArray()[0].Get().Value);
                Assert.AreEqual(19, (int)xCell.Root.Elements().ToArray()[5].Get().Value);
                Assert.AreEqual(90, (int)xCell.Root.Elements().ToArray()[7].Get().Value);

            }
            finally
            {
                xCell.Close();
            }
        }