Exemplo n.º 1
0
        public void testSelectServerRoundrobin()
        {
            using (var conn = new CrateConnection("localhost:9999, localhost:4200")) {
                conn.Open();

                for (int i = 0; i < 10; i++)
                {
                    string clusterName = conn.Query <string>("select name from sys.cluster").First();
                    Assert.AreEqual("crate", clusterName);
                }
            }
        }
Exemplo n.º 2
0
        public void testWithDapper()
        {
            using (var conn = new CrateConnection()) {
                conn.Open();
                var clusterName = conn.Query <string>("select name from sys.cluster").First();
                Assert.AreEqual(clusterName, "crate");

                clusterName = conn.Query <string>(
                    "select name from sys.cluster where name = ?", new { Name = "crate" }).First();
                Assert.AreEqual(clusterName, "crate");

                conn.Execute(
                    "create table foo (id int primary key, name string) with (number_of_replicas='0-1')");
                Assert.AreEqual(1,
                                conn.Execute("insert into foo (id, name) values (?, ?)", new { id = 1, name = "foo" }));

                int rowsAffected = conn.Execute(
                    "insert into foo (id, name) values (?, ?), (?, ?)",
                    new { id1 = 2, name1 = "zwei", id2 = 3, name2 = "drei" }
                    );
                Assert.AreEqual(2, rowsAffected);
                conn.Execute("drop table foo");
            }
        }