0
此測試用例將在第一次通過,但接下來將失敗。我不知道爲什麼在第二次執行插入方法後沒有將列值更新爲「value1」。無法通過節儉api更新列值
[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));
感謝您的幫助。我使用了私有靜態只讀DateTime Jan1st1970 = new DateTime(1970,1,1,0,0,0,DateTimeKind.Utc); \t \t公共靜態長的currentTimeMillis \t \t { \t \t \t得到{(長)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds; } \t \t},並解決此問題。 – 2013-03-27 06:10:41