Exemple #1
0
 public void ASSERT_ACTION(Client client, String expected)
 {
     String got = client.Action;
     if (expected != got) {
         fail(string.Format("ASSERT_ACTION failed: expected {0} got {1}", expected, got));
     }
 }
Exemple #2
0
 public void ASSERT_COLUMN_COUNT(Client client, int expected)
 {
     int got = client.ColumnCount;
     if (expected != got) {
         fail(string.Format("ASSERT_COLUMN_COUNT failed: expected {0} but got {1}", expected, got));
     }
 }
Exemple #3
0
 public void ASSERT_CONNECTED(Client client, bool expected)
 {
     bool got = client.Connected;
     if (expected != got) {
         fail(string.Format("ASSERT_CONNECTED failed: expected {0} got {1}", expected, got));
     }
 }
Exemple #4
0
 public void ASSERT_CONNECT(Client client, String address, bool expected)
 {
     bool got = true;
     try
     {
         client.Connect(address);
     }
     catch (Exception )
     {
         got = false;
     }
     if (expected != got) {
         fail(string.Format("ASSERT_CONNECT failed: expected {0} got {1} ", expected, got));
     }
 }
Exemple #5
0
 public void ASSERT_EXECUTE(Client client, String command, bool expected)
 {
     bool got = true;
     try
     {
         client.Execute(command);
     }
     catch (Exception)
     {
         got = false;
     }
     if (expected != got) {
         fail(string.Format("ASSERT_EXECUTE failed: expected {0} got {1}", expected, got));
     }
 }
Exemple #6
0
 public void TestPubSubUpdate()
 {
     newtable();
     insertRows();
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     String command = string.Format("subscribe skip * from {0}", TABLE);
     // subscribe
     ASSERT_EXECUTE(client, command, true);
     ASSERT_ACTION(client, "subscribe");
     ASSERT_PUBSUBID(client);
     String pubsubid = client.PubSubId;
     // generate update event
     command = string.Format("update {0} set col1 = newvalue", TABLE);
     ASSERT_EXECUTE(client, command, true);
     ASSERT_ROW_COUNT(client, ROWS);
     // expected id and updated column (col1)
     ASSERT_PUBSUB_RESULT_SET(client, pubsubid, "update", ROWS, 2);
     ASSERT_DISCONNECT(client);
 }
Exemple #7
0
 public void TestSelectManyRows()
 {
     newtable();
     insertRows();
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     String command = string.Format("select * from {0}", TABLE);
     ASSERT_EXECUTE(client, command, true);
     ASSERT_ACTION(client, "select");
     ASSERT_ROW_COUNT(client, ROWS);
     for (int row = 0; row < ROWS; row++) {
         ASSERT_NEXT_ROW(client, true);
         ASSERT_ID(client);
         ASSERT_VALUE(client, "col1", row + ":col1", true);
         ASSERT_VALUE(client, "col2", row + ":col2", true);
         ASSERT_VALUE(client, "col3", row + ":col3", true);
         ASSERT_HAS_COLUMN(client, "col1", true);
         ASSERT_HAS_COLUMN(client, "col2", true);
         ASSERT_HAS_COLUMN(client, "col3", true);
         ASSERT_COLUMN_COUNT(client, 4); // including id
     }
     //
     ASSERT_NEXT_ROW(client, false);
     ASSERT_DISCONNECT(client);
 }
Exemple #8
0
 public void TestPubSubRemove()
 {
     newtable();
     insertRows();
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     // key col1
     String command = string.Format("key {0} col1", TABLE);
     ASSERT_EXECUTE(client, command, true);
     command = string.Format("subscribe skip * from {0} where col1 = 1:col1", TABLE);
     ASSERT_EXECUTE(client, command, true);
     String pubsubid = client.PubSubId;
     // generate remove event
     command = string.Format("update {0} set col1 = newvalue where col1 = 1:col1", TABLE);
     ASSERT_EXECUTE(client, command, true);
     ASSERT_PUBSUB_RESULT_SET(client, pubsubid, "remove", 1, COLUMNS);
     ASSERT_DISCONNECT(client);
 }
Exemple #9
0
 public void TestPubSubTimeout()
 {
     newtable();
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     ASSERT_WAIT_FOR_PUBSUB(client, 10, false);
 }
Exemple #10
0
 public void TestTag()
 {
     newtable();
     insertRows();
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     String command = string.Format("tag {0} col1", TABLE);
     ASSERT_EXECUTE(client, command, true);
     ASSERT_ACTION(client, "tag");
     ASSERT_DISCONNECT(client);
 }
Exemple #11
0
 public void tag(String column)
 {
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     String command = string.Format("tag {0} {1}", TABLE, column);
     ASSERT_EXECUTE(client, command, true);
     ASSERT_DISCONNECT(client);
 }
Exemple #12
0
 public void TestInsertOneRow()
 {
     newtable();
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     String command = string.Format("insert into {0} (col1, col2, col3) values (1:col1, 1:col2, 1:col3) returning *", TABLE);
     ASSERT_EXECUTE(client, command, true);
     ASSERT_ACTION(client, "insert");
     ASSERT_ROW_COUNT(client, 1);
     ASSERT_NEXT_ROW(client, true);
     ASSERT_ID(client);
     ASSERT_VALUE(client, "col1", "1:col1", true);
     ASSERT_VALUE(client, "col2", "1:col2", true);
     ASSERT_VALUE(client, "col3", "1:col3", true);
     ASSERT_HAS_COLUMN(client, "col1", true);
     ASSERT_HAS_COLUMN(client, "col2", true);
     ASSERT_HAS_COLUMN(client, "col3", true);
     ASSERT_COLUMN_COUNT(client, 4); // including id
     ASSERT_NEXT_ROW(client, false);
     ASSERT_DISCONNECT(client);
 }
Exemple #13
0
 public void TestSubscribeSkip()
 {
     newtable();
     insertRows();
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     String command = string.Format("subscribe skip * from {0}", TABLE);
     ASSERT_EXECUTE(client, command, true);
     ASSERT_ACTION(client, "subscribe");
     ASSERT_PUBSUBID(client);
     ASSERT_WAIT_FOR_PUBSUB(client, 10, false);
     ASSERT_DISCONNECT(client);
 }
Exemple #14
0
 public void TestExecuteInvalidCommand()
 {
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     ASSERT_EXECUTE(client, "blablabla", false);
 }
Exemple #15
0
 public void TestExecuteStatus()
 {
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     ASSERT_EXECUTE(client, "status", true);
     ASSERT_ACTION(client, "status");
     ASSERT_DISCONNECT(client);
 }
Exemple #16
0
 public void insertRow()
 {
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     String command = string.Format("insert into {0} (col1, col2, col3) values (1:col1, 1:col2, 1:col3)", TABLE);
     ASSERT_EXECUTE(client, command, true);
     ASSERT_DISCONNECT(client);
 }
Exemple #17
0
 public void TestDeleteOneRow()
 {
     newtable();
     insertRow();
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     String command = string.Format("delete from {0}", TABLE);
     ASSERT_EXECUTE(client, command, true);
     ASSERT_ACTION(client, "delete");
     ASSERT_ROW_COUNT(client, 1);
     ASSERT_DISCONNECT(client);
 }
Exemple #18
0
 public void TestConnectDisconnect()
 {
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     ASSERT_CONNECTED(client, true);
     ASSERT_DISCONNECT(client);
     ASSERT_CONNECT(client, "addresswithnoport", false);
     ASSERT_CONNECTED(client, false);
     ASSERT_DISCONNECT(client);
     ASSERT_CONNECT(client, "addresswithnoport:", false);
     ASSERT_CONNECTED(client, false);
     ASSERT_DISCONNECT(client);
     ASSERT_CONNECT(client, "localhost:7778", false);
     ASSERT_CONNECTED(client, false);
     ASSERT_DISCONNECT(client);
 }
Exemple #19
0
 public void TestSelectOneRow()
 {
     newtable();
     insertRow();
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     // select one row
     String command = string.Format("select * from {0}", TABLE);
     ASSERT_EXECUTE(client, command, true);
     ASSERT_ACTION(client, "select");
     ASSERT_ROW_COUNT(client, 1);
     ASSERT_NEXT_ROW(client, true);
     //
     ASSERT_ID(client);
     ASSERT_VALUE(client, "col1", "1:col1", true);
     ASSERT_VALUE(client, "col2", "1:col2", true);
     ASSERT_VALUE(client, "col3", "1:col3", true);
     ASSERT_HAS_COLUMN(client, "col1", true);
     ASSERT_HAS_COLUMN(client, "col2", true);
     ASSERT_HAS_COLUMN(client, "col3", true);
     ASSERT_COLUMN_COUNT(client, 4); // including id
     //
     ASSERT_NEXT_ROW(client, false);
     ASSERT_DISCONNECT(client);
 }
Exemple #20
0
 public void TestUpdateOneRow()
 {
     newtable();
     insertRow();
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     String command = string.Format("update {0} set col1 = newvalue", TABLE);
     ASSERT_EXECUTE(client, command, true);
     ASSERT_ACTION(client, "update");
     ASSERT_ROW_COUNT(client, 1);
     ASSERT_DISCONNECT(client);
 }
Exemple #21
0
 public void ASSERT_WAIT_FOR_PUBSUB(Client client, int timeout, bool expected)
 {
     bool got = true;
     try
     {
         got = client.WaitForPubSub(timeout);
     }
     catch (Exception e)
     {
         fail(string.Format("ASSERT_WAIT_FOR_PUBSUB failed: {0}", e.Message));
     }
     if (expected != got) {
         fail(string.Format("ASSERT_WAIT_FOR_PUBSUB failed: expected {0} but got {1}", expected, got));
     }
 }
Exemple #22
0
 public void ASSERT_HAS_COLUMN(Client client, String column, bool expected)
 {
     bool got = client.HasColumn(column);
     if (expected != got) {
         fail(string.Format("ASSERT_HAS_COLUMN failed: expected {0} but got {1}", expected, got));
     }
 }
Exemple #23
0
 public void TestSubscribeUnsubscribeByPubSubId()
 {
     newtable();
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     String command = string.Format("subscribe * from {0}", TABLE);
     // subscribe
     ASSERT_EXECUTE(client, command, true);
     ASSERT_ACTION(client, "subscribe");
     ASSERT_PUBSUBID(client);
     // unsubscribe
     command = string.Format("unsubscribe from {0} where pubsubid = {1}", TABLE, client.PubSubId);
     ASSERT_EXECUTE(client, command, true);
     ASSERT_ACTION(client, "unsubscribe");
     //
     ASSERT_DISCONNECT(client);
 }
Exemple #24
0
 public void ASSERT_VALUE(Client client, String column, String value, bool match)
 {
     String got = client.GetValue(column);
     if (match && value != got) {
         fail(string.Format("ASSERT_VALUE failed: expected {0} but got {1}", value, got));
     }
     else if (!match && value == got) {
         fail(string.Format("ASSERT_VALUE failed: not expected {0}", value));
     }
 }
Exemple #25
0
 public void ASSERT_DISCONNECT(Client client)
 {
     client.Disconnect();
 }
Exemple #26
0
 public void insertRows()
 {
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     for (int row = 0; row < ROWS; row++) {
         String command = string.Format("insert into {0} (col1, col2, col3) values ({1}:col1, {2}:col2, {3}:col3)", TABLE, row, row, row);
         ASSERT_EXECUTE(client, command, true);
     }
     ASSERT_DISCONNECT(client);
 }
Exemple #27
0
 public void TestPubSubAddOnSubscribe()
 {
     newtable();
     insertRows();
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     String command = string.Format("subscribe * from {0}", TABLE);
     // subscribe
     ASSERT_EXECUTE(client, command, true);
     ASSERT_ACTION(client, "subscribe");
     ASSERT_PUBSUBID(client);
     // pubsub add
     String pubsubid = client.PubSubId;
     ASSERT_PUBSUB_RESULT_SET(client, pubsubid, "add", ROWS, COLUMNS);
     ASSERT_DISCONNECT(client);
 }
Exemple #28
0
 public void TestPubSubInsert()
 {
     newtable();
     Client client = new Client();
     ASSERT_CONNECT(client, ADDRESS, true);
     String command = string.Format("subscribe * from {0}", TABLE);
     // subscribe
     ASSERT_EXECUTE(client, command, true);
     ASSERT_ACTION(client, "subscribe");
     ASSERT_PUBSUBID(client);
     // generate insert event
     insertRows();
     // pubsub insert
     ASSERT_PUBSUB_RESULT_SET(client, client.PubSubId, "insert", ROWS, COLUMNS);
     ASSERT_DISCONNECT(client);
 }
Exemple #29
0
 public void ASSERT_ID(Client client)
 {
     String id = client.GetValue("id");
     if (string.IsNullOrEmpty(id)) {
         fail("ASSERT_ID failed: expected non empty string");
     }
 }
Exemple #30
0
 public void ASSERT_RESULT_SET(Client client, int rows, int columns)
 {
     ASSERT_ROW_COUNT(client, rows);
     for (int row = 0; row < rows; row++) {
         ASSERT_NEXT_ROW(client, true);
         ASSERT_COLUMN_COUNT(client, columns);
         for (int col = 0; col < columns; col++) {
             ASSERT_NON_EMPTY_VALUE(client, col);
         }
     }
     ASSERT_NEXT_ROW(client, false);
 }