public void get_current_version() { using (var store = new FileAppendOnlyStore(new DirectoryInfo(_storePath))) { store.Initialize(); var currentVersion = store.GetCurrentVersion(); store.Append("versiontest", Encoding.UTF8.GetBytes("test message1")); store.Append("versiontest", Encoding.UTF8.GetBytes("test message2")); store.Append("versiontest", Encoding.UTF8.GetBytes("test message3")); Assert.AreEqual(currentVersion + 3, store.GetCurrentVersion()); } }
public void read_store_all_records() { var stream = Guid.NewGuid().ToString(); using (var store = new FileAppendOnlyStore(new DirectoryInfo(_storePath))) { store.Initialize(); var currentVersion = store.GetCurrentVersion(); for (int i = 0; i < 2; i++) { store.Append(stream, Encoding.UTF8.GetBytes("test message" + i)); } var records = store.ReadRecords(-1, Int32.MaxValue).ToArray(); Assert.AreEqual(currentVersion + 2, records.Length); for (var i = currentVersion; i < currentVersion + 2; i++) { Assert.AreEqual("test message" + (i - currentVersion), Encoding.UTF8.GetString(records[i].Data)); Assert.AreEqual(i - currentVersion + 1, records[i].StreamVersion); Assert.AreEqual(i + 1, records[i].StoreVersion); } } }
public void append_data_when_set_version_where_does_not_correspond_real_version() { var key = Guid.NewGuid().ToString(); using (var store = new FileAppendOnlyStore(new DirectoryInfo(_storePath))) { store.Initialize(); store.Append(key, Encoding.UTF8.GetBytes("test message1"), 100); var data = store.ReadRecords(key, -1, 2).ToArray(); CollectionAssert.IsEmpty(data); } }
public void append_data() { using (var store = new FileAppendOnlyStore(new DirectoryInfo(_storePath))) { store.Initialize(); var currentVersion = store.GetCurrentVersion(); const int messagesCount = 3; for (int i = 0; i < messagesCount; i++) { store.Append("stream1", Encoding.UTF8.GetBytes("test message" + i)); } var data = store.ReadRecords("stream1", currentVersion, Int32.MaxValue).ToArray(); for (int i = 0; i < messagesCount; i++) { Assert.AreEqual("test message" + i, Encoding.UTF8.GetString(data[i].Data)); } Assert.AreEqual(messagesCount, data.Length); } }