这个测试用例第一次会通过,但接下来会失败。我不知道为什么它在第二次执行插入方法后没有将列值更新为“value1”。
[TestMethod]
public void TestMethod()
{
client.set_keyspace(KEYSPACE);
byte[] key = utf8Encoding.GetBytes("123456789");
ColumnParent parent = new ColumnParent();
parent.Column_family = "Users";
Column column = new Column();
column.Name = utf8Encoding.GetBytes("columnname1");
column.Timestamp = DateTime.Now.Millisecond;
column.Value = utf8Encoding.GetBytes("value1");
// insert
client.insert(key, parent, column, ConsistencyLevel.ONE);
ColumnPath path = new ColumnPath();
path.Column_family = "Users";
path.Column = utf8Encoding.GetBytes("columnname1");
// search
ColumnOrSuperColumn returnedColumn = client.get(key, path, ConsistencyLevel.ONE);
Assert.AreEqual("value1", utf8Encoding.GetString(returnedColumn.Column.Value));
// update
column.Timestamp = DateTime.Now.Millisecond;
column.Value = utf8Encoding.GetBytes("value2");
client.insert(key, parent, column, ConsistencyLevel.ONE);
returnedColumn = client.get(key, path, ConsistencyLevel.ONE);
Assert.AreEqual("value2", utf8Encoding.GetString(returnedColumn.Column.Value));