Example #1
0
        public void WindowedKeyValueEnumeratorTestDispose()
        {
            var date  = DateTime.Now;
            var key   = new Bytes(Encoding.UTF8.GetBytes("key"));
            var store = new InMemoryWindowStore("store", TimeSpan.FromSeconds(10),
                                                (long)TimeSpan.FromSeconds(1).TotalMilliseconds);

            store.Put(key, Encoding.UTF8.GetBytes("value"), date.GetMilliseconds());

            var enumerator = new MeteredWindowedKeyValueEnumerator <string, string>(
                store.All(),
                (b) => (new StringSerDes()).Deserialize(b, new SerializationContext()),
                (b) => (new StringSerDes()).Deserialize(b, new SerializationContext()),
                new NoRunnableSensor("s", "s", MetricsRecordingLevel.INFO));

            enumerator.Dispose();
            Assert.Throws <ObjectDisposedException>(() => enumerator.MoveNext());
        }