コード例 #1
0
        public void TestIncrementByOne()
        {
            var KEY = GetKey();

            Assert.False(_redis.Exists(KEY));

            Assert.Equal(1, _redis.Increment(KEY));
            Assert.Equal(2, _redis.Increment(KEY));
            Assert.Equal(3, _redis.Increment(KEY));
            Assert.Equal(4, _redis.Increment(KEY));
            Assert.Equal(5, _redis.Increment(KEY));

            Assert.Equal(4, _redis.Decrement(KEY));
            Assert.Equal(3, _redis.Decrement(KEY));
            Assert.Equal(2, _redis.Decrement(KEY));
            Assert.Equal(1, _redis.Decrement(KEY));
            Assert.Equal(0, _redis.Decrement(KEY));

            ((Zongsoft.Common.ISequence)_redis).Reset(KEY);
            Assert.Equal(0, (int)_redis.GetValue(KEY));

            Assert.True(_redis.Remove(KEY));
            Assert.False(_redis.Exists(KEY));
        }