Example #1
0
        public void When_Decrementing_value_on_cache_which_is_in_valid_format_use_this_as_base()
        {
            Cache["foo"] = new CachedItem {
                Buffer = Encoding.ASCII.GetBytes("12")
            };
            var stream  = new MemoryStream();
            var command = new DecrCommand();

            command.SetContext(stream);

            command.Init("foo", "5");

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

            Assert.AreEqual("7\r\n", ReadAll(stream));

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

            Assert.AreEqual("2\r\n", ReadAll(3, stream));
        }
        public void When_Decrementing_value_on_cache_below_zero_will_set_to_zero()
        {
            Cache["foo"] = new CachedItem { Buffer = Encoding.ASCII.GetBytes("12") };
            var stream = new MemoryStream();
            var command = new DecrCommand();
            command.SetContext(stream);
            command.Init("foo", "15");

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

            Assert.AreEqual("0\r\n", ReadAll(stream));
        }
Example #3
0
        public void When_Decrementing_value_on_cache_below_zero_will_set_to_zero()
        {
            Cache["foo"] = new CachedItem {
                Buffer = Encoding.ASCII.GetBytes("12")
            };
            var stream  = new MemoryStream();
            var command = new DecrCommand();

            command.SetContext(stream);
            command.Init("foo", "15");

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

            Assert.AreEqual("0\r\n", ReadAll(stream));
        }
        public void When_Decrementing_value_on_cache_which_is_in_valid_format_use_this_as_base()
        {
            Cache["foo"] = new CachedItem { Buffer = Encoding.ASCII.GetBytes("12") };
            var stream = new MemoryStream();
            var command = new DecrCommand();
            command.SetContext(stream);

            command.Init("foo", "5");

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

            Assert.AreEqual("7\r\n", ReadAll(stream));

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

            Assert.AreEqual("2\r\n", ReadAll(3, stream));
        }