Ejemplo n.º 1
0
        public void Test1()
        {
            string        url       = "server=localhost;database=devtest;uid=dev;pwd=devtest12345";
            DatabaseMySql sqlserver = new DatabaseMySql(url);

            Database.Table table = sqlserver.OpenTable("test_1");
            sqlserver.Flush(null,
                            () =>
            {
                {
                    ByteBuffer key = ByteBuffer.Allocate();
                    key.WriteInt(1);
                    table.Remove(key);
                }
                {
                    ByteBuffer key = ByteBuffer.Allocate();
                    key.WriteInt(2);
                    table.Remove(key);
                }
            }
                            );
            Assert.AreEqual(0, table.Walk(PrintRecord));
            sqlserver.Flush(null,
                            () =>
            {
                {
                    ByteBuffer key = ByteBuffer.Allocate();
                    key.WriteInt(1);
                    ByteBuffer value = ByteBuffer.Allocate();
                    value.WriteInt(1);
                    table.Replace(key, value);
                }
                {
                    ByteBuffer key = ByteBuffer.Allocate();
                    key.WriteInt(2);
                    ByteBuffer value = ByteBuffer.Allocate();
                    value.WriteInt(2);
                    table.Replace(key, value);
                }
            }
                            );
            {
                ByteBuffer key = ByteBuffer.Allocate();
                key.WriteInt(1);
                ByteBuffer value = table.Find(key);
                Assert.IsNotNull(value);
                Assert.AreEqual(1, value.ReadInt());
                Assert.IsTrue(value.ReadIndex == value.WriteIndex);
            }
            {
                ByteBuffer key = ByteBuffer.Allocate();
                key.WriteInt(2);
                ByteBuffer value = table.Find(key);
                Assert.IsNotNull(value);
                Assert.AreEqual(2, value.ReadInt());
                Assert.IsTrue(value.ReadIndex == value.WriteIndex);
            }
            Assert.AreEqual(2, table.Walk(PrintRecord));
        }
Ejemplo n.º 2
0
        public void Test1()
        {
            string            url       = "Server=(localdb)\\MSSQLLocalDB;Integrated Security=true";
            DatabaseSqlServer sqlserver = new DatabaseSqlServer(url);

            Database.Table table = sqlserver.OpenTable("test1");
            sqlserver.Flush(null,
                            () =>
            {
                {
                    ByteBuffer key = ByteBuffer.Allocate();
                    key.WriteInt(1);
                    table.Remove(key);
                }
                {
                    ByteBuffer key = ByteBuffer.Allocate();
                    key.WriteInt(2);
                    table.Remove(key);
                }
            }
                            );
            Assert.AreEqual(0, table.Walk(PrintRecord));
            sqlserver.Flush(null,
                            () =>
            {
                {
                    ByteBuffer key = ByteBuffer.Allocate();
                    key.WriteInt(1);
                    ByteBuffer value = ByteBuffer.Allocate();
                    value.WriteInt(1);
                    table.Replace(key, value);
                }
                {
                    ByteBuffer key = ByteBuffer.Allocate();
                    key.WriteInt(2);
                    ByteBuffer value = ByteBuffer.Allocate();
                    value.WriteInt(2);
                    table.Replace(key, value);
                }
            }
                            );
            {
                ByteBuffer key = ByteBuffer.Allocate();
                key.WriteInt(1);
                ByteBuffer value = table.Find(key);
                Assert.IsNotNull(value);
                Assert.AreEqual(1, value.ReadInt());
                Assert.IsTrue(value.ReadIndex == value.WriteIndex);
            }
            {
                ByteBuffer key = ByteBuffer.Allocate();
                key.WriteInt(2);
                ByteBuffer value = table.Find(key);
                Assert.IsNotNull(value);
                Assert.AreEqual(2, value.ReadInt());
                Assert.IsTrue(value.ReadIndex == value.WriteIndex);
            }
            Assert.AreEqual(2, table.Walk(PrintRecord));
        }