Esempio n. 1
0
        public void When_prepending_item_on_cache_will_reply_with_stored()
        {
            var      buffer  = new byte[] { 1, 2, 3, 4 };
            ICommand command = new SetCommand();

            command.SetContext(GetStreamWithData(buffer));
            command.Init("foo", "1", "6000", "4");

            command.FinishedExecuting += () => { wait.Set(); };
            command.Execute();
            wait.WaitOne();

            wait.Reset();

            buffer = new byte[] { 5, 6, 7, 8 };
            MemoryStream stream = GetStreamWithData(buffer);

            command = new PrependCommand();
            command.SetContext(stream);
            command.Init("foo", "1", "6000", "4");

            command.FinishedExecuting += () => { wait.Set(); };
            command.Execute();
            wait.WaitOne();

            Assert.AreEqual("STORED\r\n", ReadAll(6, stream));
        }
Esempio n. 2
0
        public void When_prepending_item_on_cache_will_prepend_to_data_already_on_cache()
        {
            var      buffer  = new byte[] { 1, 2, 3, 4 };
            ICommand command = new SetCommand();

            command.SetContext(GetStreamWithData(buffer));
            command.Init("foo", "1", "6000", "4");

            command.FinishedExecuting += () => { wait.Set(); };
            command.Execute();
            wait.WaitOne();

            wait.Reset();

            buffer = new byte[] { 5, 6, 7, 8 };
            MemoryStream stream = GetStreamWithData(buffer);

            command = new PrependCommand();
            command.SetContext(stream);
            command.Init("foo", "1", "6000", "4");

            command.FinishedExecuting += () => { wait.Set(); };
            command.Execute();
            wait.WaitOne();

            var item = (CachedItem)Cache.Get("foo");

            CollectionAssert.AreEqual(new byte[] { 5, 6, 7, 8, 1, 2, 3, 4, }, item.Buffer);
        }
Esempio n. 3
0
        public void When_prepending_item_on_cache_will_not_modify_flags()
        {
            var      buffer  = new byte[] { 1, 2, 3, 4 };
            ICommand command = new SetCommand();

            command.SetContext(GetStreamWithData(buffer));
            command.Init("foo", "1", "6000", "4");

            command.FinishedExecuting += () => { wait.Set(); };
            command.Execute();
            wait.WaitOne();

            wait.Reset();

            buffer = new byte[] { 5, 6, 7, 8 };
            MemoryStream stream = GetStreamWithData(buffer);

            command = new PrependCommand();
            command.SetContext(stream);
            command.Init("foo", "15", "6000", "4");

            command.FinishedExecuting += () => { wait.Set(); };
            command.Execute();
            wait.WaitOne();

            var item = (CachedItem)Cache.Get("foo");

            Assert.AreEqual(1, item.Flags);
        }