Пример #1
0
        public void Fill2VolumedSeqRecordWithRestTest()
        {
            var seqtriplets = new PTypeSequence(new PType(PTypeEnumeration.integer));
            var testdb = new object[] { 1, 2, 3, 5, 15, 19, 21, 90, 100, 13 };

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

            try
            {
                Assert.AreEqual(10, 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);
                Assert.AreEqual(13, (int)xCell.Root.Element(9).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);
                Assert.AreEqual(100, (int)xCell.Root.Elements().ToArray()[8].Get().Value);

            }
            finally
            {
                xCell.Close();
            }
        }
Пример #2
0
        public void SimpleSortRecordTest()
        {
            PType tp_seq = new PTypeSequence(new PTypeRecord(
                new NamedType("name", new PType(PTypeEnumeration.sstring)),
                new NamedType("id", new PType(PTypeEnumeration.sstring))));

            object[] testdb = new object[] {
                new object[] { "Petr", "0120"},
                new object[] { "Dan", "12"},
                new object[] { "Ivan", "54"},
                new object[] { "Jim", "13"},
                new object[] { "Wai", "1"},
                new object[] { "Ken", "15"},
                new object[] { "Aby", "916"},
            };

            string testpacfilename = "test.pxc";
            PxCell xCell = new PxCell(tp_seq, testpacfilename, false);
            try
            {
                xCell.Fill2(testdb);

                Assert.AreEqual(7, xCell.Root.Count());
                Assert.AreEqual("Ivan", xCell.Root.Element(2).Field(0).Get().Value.ToString());
                Assert.AreEqual("Jim", xCell.Root.Element(3).Field(0).Get().Value.ToString());
                Assert.AreEqual("Ken", xCell.Root.Element(5).Field(0).Get().Value.ToString());
                Assert.AreEqual("Aby", xCell.Root.Element(6).Field(0).Get().Value.ToString());

                xCell.Root.Sort(e =>
                {
                    return (string)e.Field(0).Get().Value;
                });

                Assert.AreEqual(7, xCell.Root.Count());
                Assert.AreEqual("Ivan", xCell.Root.Element(2).Field(0).Get().Value.ToString());
                Assert.AreEqual("Jim", xCell.Root.Element(3).Field(0).Get().Value.ToString());
                Assert.AreEqual("Petr", xCell.Root.Element(5).Field(0).Get().Value.ToString());
                Assert.AreEqual("Wai", xCell.Root.Element(6).Field(0).Get().Value.ToString());
            }
            finally
            {
                xCell.Close();
            }
        }
Пример #3
0
        public void Fill2SeqWithVolumeTest()
        {
            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.Fill2(testdb);

            CheckSequence(xCell);
        }
Пример #4
0
 public void Fill2Test()
 {
     string testpacfilename = "test.pxc";
     PxCell xCell = new PxCell(seqtriplets, testpacfilename, false);
     try
     {
         xCell.Fill2(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();
     }
 }
Пример #5
0
        public void TestFillPxCellWhenRecordHasLongValue()
        {
            seqtriplets = new PTypeSequence(
                new PTypeUnion(
                    new NamedType("op",
                        new PTypeRecord(
                            new NamedType("test1", new PType(PTypeEnumeration.sstring)))),
                    new NamedType("testindex", new PType(PTypeEnumeration.longinteger)),
                    new NamedType("dp",
                        new PTypeRecord(
                            new NamedType("subject", new PType(PTypeEnumeration.sstring)),
                            new NamedType("lang", new PType(PTypeEnumeration.sstring)))))
                            );

            testdb = new object[] {
                new object[] { 0, new object[] {"a"}},
                new object[] { 1, 4L},
                new object[] { 2, new object[] {"da", "lang"}}
            };

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

            try
            {
                xCell.Fill2(testdb);
                Assert.AreEqual(3, xCell.Root.Count());
                var e = (object[])xCell.Root.Element(0).Get().Value;
                Assert.AreEqual(e.Length, 2);
                Assert.AreEqual(((object[])e[1])[0], "a");
                var e1 = (object[])xCell.Root.Element(1).Get().Value;
                Assert.AreEqual(e1.Length, 2);
                Assert.AreEqual(e1[0], 1);
                Assert.AreEqual(e1[1], 4L);

                var e2 = (object[])xCell.Root.Element(2).Get().Value;
                Assert.AreEqual(e2.Length, 2);
                Assert.AreEqual(((object[])e2[1])[0], "da");
                Assert.AreEqual(((object[])e2[1])[1], "lang");
            }
            finally
            {
                xCell.Close();
            }
        }
Пример #6
0
        public void TestFillPxCell2()
        {
            seqtriplets = new PTypeSequence(
                   new PTypeRecord(
                            new NamedType("test1", new PType(PTypeEnumeration.sstring)),
                            new NamedType("subject", new PType(PTypeEnumeration.sstring)),
                            new NamedType("lang", new PType(PTypeEnumeration.sstring))
                    )
               );

            testdb = new object[] {
                new object[] {
                        "a",
                        "1L",
                        "dalang"},
                new object[] {
                        "b",
                        "2L",
                        "dalang"},
                new object[] {
                        "c",
                        "3L",
                        "dalang"}
            };

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

            try
            {
                xCell.Fill2(testdb);
                var i = xCell.Root.Count();
                var e = (object[])xCell.Root.Element(0).Get().Value;
            }
            finally
            {
                xCell.Close();
            }
        }