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(); } }
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(); } }
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(); } }
private static void CheckSequence(PxCell xCell) { try { Assert.AreEqual(9, xCell.Root.Count()); var e = (object[])xCell.Root.Element(0).Get().Value; Assert.IsInstanceOfType(e[1], typeof(object[])); Assert.AreEqual(e[0], 0); var o = (object[])e[1]; Assert.AreEqual(o[0], "a"); Assert.AreEqual(o[1], 'c'); e = (object[])xCell.Root.Element(2).Get().Value; Assert.IsInstanceOfType(e[1], typeof(object[])); Assert.AreEqual(e[0], 1); o = (object[])e[1]; Assert.AreEqual(o[0], "da"); Assert.AreEqual(o[1], 3); Assert.AreEqual(o[2], true); e = (object[])xCell.Root.Element(3).Get().Value; Assert.IsInstanceOfType(e[1], typeof(object[])); Assert.AreEqual(e[0], 0); o = (object[])e[1]; Assert.AreEqual(o[0], "a1"); Assert.AreEqual(o[1], '1'); e = (object[])xCell.Root.Element(4).Get().Value; Assert.IsInstanceOfType(e[1], typeof(object[])); Assert.AreEqual(e[0], 1); o = (object[])e[1]; Assert.AreEqual(o[0], "da1"); Assert.AreEqual(o[1], 7); Assert.AreEqual(o[2], true); e = (object[])xCell.Root.Element(5).Get().Value; Assert.IsInstanceOfType(e[1], typeof(object[])); Assert.AreEqual(e[0], 0); o = (object[])e[1]; Assert.AreEqual(o[0], "a2"); Assert.AreEqual(o[1], '2'); e = (object[])xCell.Root.Element(7).Get().Value; Assert.IsInstanceOfType(e[1], typeof(object[])); Assert.AreEqual(e[0], 1); o = (object[])e[1]; Assert.AreEqual(o[0], "da2"); Assert.AreEqual(o[1], 11); Assert.AreEqual(o[2], true); e = (object[])xCell.Root.Elements().ToArray()[0].Get().Value; Assert.IsInstanceOfType(e[1], typeof(object[])); Assert.AreEqual(e[0], 0); o = (object[])e[1]; Assert.AreEqual(o[0], "a"); Assert.AreEqual(o[1], 'c'); e = (object[])xCell.Root.Elements().ToArray()[5].Get().Value; Assert.IsInstanceOfType(e[1], typeof(object[])); Assert.AreEqual(e[0], 0); o = (object[])e[1]; Assert.AreEqual(o[0], "a2"); Assert.AreEqual(o[1], '2'); e = (object[])xCell.Root.Elements().ToArray()[7].Get().Value; Assert.IsInstanceOfType(e[1], typeof(object[])); Assert.AreEqual(e[0], 1); o = (object[])e[1]; Assert.AreEqual(o[0], "da2"); Assert.AreEqual(o[1], 11); Assert.AreEqual(o[2], true); e = (object[])xCell.Root.Elements().Last().Get().Value; Assert.IsInstanceOfType(e[1], typeof(object[])); Assert.AreEqual(e[0], 1); o = (object[])e[1]; Assert.AreEqual(o[0], "da3"); Assert.AreEqual(o[1], 13); Assert.AreEqual(o[2], false); } finally { xCell.Close(); } }
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(); } }
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(); } }