Esempio n. 1
0
 private void SetupTickingKey(string key = "tickingkey")
 {
     Observable.Interval(TimeSpan.FromTicks(1), _testScheduler)
     .Subscribe(
         i => _cache.Store(key, 0,
                           Encoding.UTF8.GetBytes(i.ToString(CultureInfo.InvariantCulture)), DateTime.MaxValue));
 }
Esempio n. 2
0
        public void EnsureStoreWritesToJournal()
        {
            _originalCache.Store("my_key", 911, Encoding.ASCII.GetBytes("Payload"), new DateTime(2013, 04, 26));

            var output = _writeStream.ToArray();

            var notification = Serializer.DeserializeWithLengthPrefix <ArchiveEntry>(
                new MemoryStream(output), PrefixStyle.Fixed32);

            Assert.IsNotNull(notification.Store);
            Assert.AreEqual("my_key", notification.Store.Key);
            // TODO: rest of the data
        }
        public void EnsureStoreNotification()
        {
            _cache.Store("key", 123, Encoding.ASCII.GetBytes("TestData"), new DateTime(1999, 1, 1));

            var notification = GetNotification();
            var store        = notification as StoreNotification;

            Assert.IsNotNull(store);
            Assert.AreEqual("key", store.Key);
            Assert.AreEqual("TestData", Encoding.ASCII.GetString(store.Data));
            Assert.AreEqual((ulong)123, store.Flags);
            Assert.AreEqual(StoreOperation.Store, store.Operation);
            Assert.AreEqual(new DateTime(1999, 1, 1), store.Expiry);
        }
Esempio n. 4
0
        public void EvictsEarliestStored()
        {
            _cache.Store("key1", 0, new byte[] { 0, 1, 2, 3, 4 }, DateTime.MaxValue);
            _cache.Store("key2", 0, new byte[] { 0, 1, 2, 3, 4 }, DateTime.MaxValue);
            _cache.Store("key3", 0, new byte[] { 0, 1, 2, 3, 4 }, DateTime.MaxValue);

            var keys = _cache.Keys.ToArray();

            Assert.AreEqual(2, keys.Length);
            Assert.IsTrue(keys.Contains("key2"));
            Assert.IsTrue(keys.Contains("key3"));
        }
Esempio n. 5
0
        public void UsedSetTest()
        {
            _cache.Store("k", 0, new byte[10], DateTime.MaxValue);

            Assert.AreEqual(10UL, _cache.Used);
        }