Ejemplo n.º 1
0
        public async Task HashMisc()
        {
            var item = new RedisValueHash("key1");

            _container.AddToContainer(item);

            await item.Set("title", "goto statement considered harmful");

            await item.Set("link", "http:go.bz");

            await item.Set("poster", "user:123");

            await item.Set("time", DateTime.Now.Ticks);

            await item.Set("votes", 122);

            Assert.IsTrue((await item.ContainsKey("poster")));
            Assert.IsTrue((await item.Get("votes")) == 122);
            await foreach (var field in item)
            {
                Console.WriteLine($"{field.Key} = {field.Value}");
            }


            Assert.IsTrue((await item.Increment("votes")) == 123);
            Assert.IsTrue((await item.Decrement("votes", 5)) == 118);

            await item.Remove("link");

            Assert.IsTrue((await item.Count()) == 4);
        }
Ejemplo n.º 2
0
 public HashTests(RedisFixture fixture)
 {
     this.container = new RedisContainer(fixture.RedisConnection, GlobalConstants.TestHashContainer);
     this.hashItem  = new RedisValueHash("hashkey");
     this.container.AddToContainer(this.hashItem);
 }