Пример #1
0
        public void given_empty_cache_and_valid_commit_function()
        {
            var cache = new LockingInMemoryCache();

            long?commitStoreVersion  = null;
            long?commitStreamVersion = null;

            cache.ConcurrentAppend("stream", GetEventBytes(1), (version, storeVersion) =>
            {
                commitStoreVersion  = storeVersion;
                commitStreamVersion = version;
            });

            Assert.AreEqual(1, commitStoreVersion, "commitStoreVersion");
            Assert.AreEqual(1, commitStreamVersion, "commitStreamVersion");

            Assert.AreEqual(1, cache.StoreVersion);

            var expected = new[]
            {
                CreateKey(1, 1, "stream"),
            };

            DataAssert.AreEqual(expected, cache.ReadStream("stream", 0, 100));
            DataAssert.AreEqual(expected, cache.ReadAll(0, 100));
        }
        public void given_empty_cache_and_valid_commit_function()
        {
            var cache = new LockingInMemoryCache();

            long? commitStoreVersion = null;
            long? commitStreamVersion = null;

            cache.ConcurrentAppend("stream", GetEventBytes(1), (version, storeVersion) =>
                {
                    commitStoreVersion = storeVersion;
                    commitStreamVersion = version;
                });

            Assert.AreEqual(1, commitStoreVersion, "commitStoreVersion");
            Assert.AreEqual(1, commitStreamVersion, "commitStreamVersion");

            Assert.AreEqual(1, cache.StoreVersion);

            var expected = new[]
                {
                    CreateKey(1, 1, "stream"),
                };
            DataAssert.AreEqual(expected, cache.ReadStream("stream",0,100));
            DataAssert.AreEqual(expected, cache.ReadAll(0, 100));
        }
Пример #3
0
 public void given_full_range()
 {
     DataAssert.AreEqual(new[]
     {
         CreateKey(1, 1, "stream1"),
         CreateKey(3, 2, "stream1")
     }, Cache.ReadStream("stream1", 0, int.MaxValue));
 }
Пример #4
0
 public void given_any_stream()
 {
     CollectionAssert.IsEmpty(Cache.ReadStream("stream1", 0, int.MaxValue));
 }
 public IEnumerable <DataWithKey> ReadRecords(string streamName, long startingFrom, int maxCount)
 {
     return(_cache.ReadStream(streamName, startingFrom, maxCount));
 }
Пример #6
0
 public IEnumerable <DataWithKey> ReadRecords(string streamName, long afterVersion, int maxCount)
 {
     return(_cache.ReadStream(streamName, afterVersion, maxCount));
 }