示例#1
0
        public void Revisions()
        {
            if (!HasHQL)
            {
                return;
            }

            Ns.Exec("CREATE TABLE fruit (tag, description)");
            Ns.Exec("INSERT INTO fruit VALUES" + "(\"2009-08-02 08:30:00\", \"banana\", \"tag:great\", \"Had with lunch\")");

            var cells = Ns.Query("SELECT * FROM fruit");

            Assert.IsNotNull(cells);
            Assert.AreEqual(1, cells.Count);
            Assert.AreEqual(cells[0].Key.Row, "banana");
            Assert.AreEqual(cells[0].Key.ColumnFamily, "tag");
            Assert.AreEqual(cells[0].Key.ColumnQualifier, "great");
            Assert.AreEqual(Encoding.Default.GetString(cells[0].Value), "Had with lunch");
            Assert.AreEqual(cells[0].Key.DateTime, new DateTime(2009, 8, 2, 8, 30, 0, DateTimeKind.Local).ToUniversalTime());

            Ns.Exec("INSERT INTO fruit VALUES" + "(\"2009-08-02 08:30:01\", \"banana\", \"tag:great\", \"Had with dinner\")");

            cells = Ns.Query("SELECT * FROM fruit");
            Assert.IsNotNull(cells);
            Assert.AreEqual(2, cells.Count);
            Assert.AreEqual(cells[0].Key.Row, "banana");
            Assert.AreEqual(cells[0].Key.ColumnFamily, "tag");
            Assert.AreEqual(cells[0].Key.ColumnQualifier, "great");
            Assert.AreEqual(Encoding.Default.GetString(cells[0].Value), "Had with dinner");
            Assert.AreEqual(cells[0].Key.DateTime, new DateTime(2009, 8, 2, 8, 30, 1, DateTimeKind.Local).ToUniversalTime());

            Assert.AreEqual(cells[1].Key.Row, "banana");
            Assert.AreEqual(cells[1].Key.ColumnFamily, "tag");
            Assert.AreEqual(cells[1].Key.ColumnQualifier, "great");
            Assert.AreEqual(Encoding.Default.GetString(cells[1].Value), "Had with lunch");
            Assert.AreEqual(cells[1].Key.DateTime, new DateTime(2009, 8, 2, 8, 30, 0, DateTimeKind.Local).ToUniversalTime());

            Ns.Exec("INSERT INTO fruit VALUES" + "(\"2009-08-02 08:30:01\", \"banana\", \"tag:great\", \"Had with breakfast\")");

            cells = Ns.Query("SELECT * FROM fruit");
            Assert.IsNotNull(cells);
            Assert.AreEqual(2, cells.Count);
            Assert.AreEqual(cells[0].Key.Row, "banana");
            Assert.AreEqual(cells[0].Key.ColumnFamily, "tag");
            Assert.AreEqual(cells[0].Key.ColumnQualifier, "great");
            Assert.AreEqual(Encoding.Default.GetString(cells[0].Value), "Had with breakfast");
            Assert.AreEqual(cells[0].Key.DateTime, new DateTime(2009, 8, 2, 8, 30, 1, DateTimeKind.Local).ToUniversalTime());

            Assert.AreEqual(cells[1].Key.Row, "banana");
            Assert.AreEqual(cells[1].Key.ColumnFamily, "tag");
            Assert.AreEqual(cells[1].Key.ColumnQualifier, "great");
            Assert.AreEqual(Encoding.Default.GetString(cells[1].Value), "Had with lunch");
            Assert.AreEqual(cells[1].Key.DateTime, new DateTime(2009, 8, 2, 8, 30, 0, DateTimeKind.Local).ToUniversalTime());

            Ns.Exec("DROP TABLE fruit");
        }
示例#2
0
        private void ValidateFruitTable(string tableName)
        {
            var cells = Ns.Query(string.Format("SELECT * FROM {0}", tableName));

            Assert.IsNotNull(cells);
            Assert.AreEqual(3, cells.Count);
            Assert.AreEqual(cells[0].Key.Row, "banana");
            Assert.AreEqual(cells[0].Key.ColumnFamily, "tag");
            Assert.AreEqual(cells[0].Key.ColumnQualifier, "great");
            Assert.AreEqual(Encoding.Default.GetString(cells[0].Value), "Had with lunch");
            Assert.AreEqual(cells[1].Key.Row, "cantelope");
            Assert.AreEqual(cells[1].Key.ColumnFamily, "tag");
            Assert.AreEqual(cells[1].Key.ColumnQualifier, "good");
            Assert.AreEqual(Encoding.Default.GetString(cells[1].Value), "Had with breakfast");
            Assert.AreEqual(cells[2].Key.Row, "cantelope");
            Assert.AreEqual(cells[2].Key.ColumnFamily, "description");
            Assert.AreEqual(cells[2].Key.ColumnQualifier, string.Empty);
            Assert.AreEqual(cells[2].Key.DateTime, new DateTime(2009, 8, 2, 8, 30, 0, DateTimeKind.Local).ToUniversalTime());
            Assert.AreEqual(Encoding.Default.GetString(cells[2].Value), "A cultivated variety of muskmelon with orange flesh");

            cells = Ns.Query(string.Format("SELECT tag FROM {0}", tableName));
            Assert.IsNotNull(cells);
            Assert.AreEqual(2, cells.Count);
            Assert.AreEqual(cells[0].Key.Row, "banana");
            Assert.AreEqual(cells[0].Key.ColumnFamily, "tag");
            Assert.AreEqual(cells[0].Key.ColumnQualifier, "great");
            Assert.AreEqual(Encoding.Default.GetString(cells[0].Value), "Had with lunch");
            Assert.AreEqual(cells[1].Key.Row, "cantelope");
            Assert.AreEqual(cells[1].Key.ColumnFamily, "tag");
            Assert.AreEqual(cells[1].Key.ColumnQualifier, "good");
            Assert.AreEqual(Encoding.Default.GetString(cells[1].Value), "Had with breakfast");

            cells = Ns.Query(string.Format("SELECT * FROM {0} WHERE ROW=\"cantelope\"", tableName));
            Assert.IsNotNull(cells);
            Assert.AreEqual(2, cells.Count);
            Assert.AreEqual(cells[0].Key.Row, "cantelope");
            Assert.AreEqual(cells[0].Key.ColumnFamily, "tag");
            Assert.AreEqual(cells[0].Key.ColumnQualifier, "good");
            Assert.AreEqual(Encoding.Default.GetString(cells[0].Value), "Had with breakfast");
            Assert.AreEqual(cells[1].Key.Row, "cantelope");
            Assert.AreEqual(cells[1].Key.ColumnFamily, "description");
            Assert.AreEqual(cells[1].Key.ColumnQualifier, string.Empty);
            Assert.AreEqual(cells[1].Key.DateTime, new DateTime(2009, 8, 2, 8, 30, 0, DateTimeKind.Local).ToUniversalTime());
            Assert.AreEqual(Encoding.Default.GetString(cells[1].Value), "A cultivated variety of muskmelon with orange flesh");
        }
示例#3
0
        public void Query()
        {
            if (!HasHQL)
            {
                return;
            }

            Ns.Exec("CREATE TABLE fruit (tag, description)");
            Ns.Exec(
                "INSERT INTO fruit VALUES" + "(\"cantelope\", \"tag:good\", \"Had with breakfast\"),"
                + "(\"2009-08-02 08:30:00\", \"cantelope\", \"description\", \"A cultivated variety of muskmelon with orange flesh\"),"
                + "(\"banana\", \"tag:great\", \"Had with lunch\")");

            ValidateFruitTable("fruit");

            Ns.Exec("DELETE description FROM fruit WHERE ROW=\"cantelope\"");

            var cells = Ns.Query("SELECT * FROM fruit", "SELECT * FROM fruit WHERE ROW=\"banana\""); // multiple queries

            Assert.IsNotNull(cells);
            Assert.AreEqual(3, cells.Count);
            Assert.AreEqual(cells[0].Key.Row, "banana");
            Assert.AreEqual(cells[0].Key.ColumnFamily, "tag");
            Assert.AreEqual(cells[0].Key.ColumnQualifier, "great");
            Assert.AreEqual(Encoding.Default.GetString(cells[0].Value), "Had with lunch");
            Assert.AreEqual(cells[1].Key.Row, "cantelope");
            Assert.AreEqual(cells[1].Key.ColumnFamily, "tag");
            Assert.AreEqual(cells[1].Key.ColumnQualifier, "good");
            Assert.AreEqual(Encoding.Default.GetString(cells[1].Value), "Had with breakfast");
            Assert.AreEqual(cells[2].Key.Row, "banana");
            Assert.AreEqual(cells[2].Key.ColumnFamily, "tag");
            Assert.AreEqual(cells[2].Key.ColumnQualifier, "great");
            Assert.AreEqual(Encoding.Default.GetString(cells[0].Value), "Had with lunch");

            Ns.Exec("DROP TABLE fruit");
        }