Exemplo n.º 1
0
 static void Decrement(IBucket bucket, string key)
 {
     var result = bucket.Decrement(key);
     if (result.Success)
     {
         Console.WriteLine(result.Value);
     }
 }
Exemplo n.º 2
0
        static void Decrement(IBucket bucket, string key)
        {
            var result = bucket.Decrement(key);

            if (result.Success)
            {
                Console.WriteLine(result.Value);
            }
        }
        public void When_Key_Is_Decremented_Past_Zero_It_Remains_At_Zero()
        {
            const string key = "When_Key_Is_Decremented_Past_Zero_It_Remains_At_Zero";

            //remove key if it exists
            _bucket.Remove(key);

            //will add the initial value
            var result = _bucket.Decrement(key);

            Assert.IsTrue(result.Success);
            Assert.AreEqual(1, result.Value);

            //decrement the key
            result = _bucket.Decrement(key);
            Assert.IsTrue(result.Success);
            Assert.AreEqual(0, result.Value);

            //Should still be zero
            result = _bucket.Decrement(key);
            Assert.IsTrue(result.Success);
            Assert.AreEqual(0, result.Value);
        }