Пример #1
0
        public void SetAndGetComplexClass()
        {
            var redisClass = new RedisClass<PersonWithAddress>(RedisServer.Default, HashKey0);
            var person = new PersonWithAddress
            {
                Name = "Matt",
                Age = 51,
                Address = new Address
                {
                    Line1 = "1234 Anywhere Street",
                    Line2 = "",
                    City = "Anywhere",
                    State = "WA",
                    Zip = "12345"
                }
            };

            var result = Task.Run(async () => { return await redisClass.Set(person); });
            var resultBool = result.Result;

            Assert.IsTrue(resultBool);

            var copy = Task.Run(async () => { return await redisClass.Get().ConfigureAwait(false); });

            var copyResult = copy.Result;

            Assert.AreEqual(person, copyResult);
        }
Пример #2
0
        public void SetAndGetComplexClass()
        {
            var person = new PersonWithAddress
            {
                Name = "Matt",
                Age = 51,
                Address = new Address
                {
                    Line1 = "1234 Anywhere Street",
                    Line2 = "",
                    City = "Anywhere",
                    State = "WA",
                    Zip = "12345"
                }
            };

            // NOTE: Pretty sure this will be the same as the string test above.
            var result = Task.Run(async () => { return await _client.AddAsync(HashKey0, person).ConfigureAwait(false); });
            var boolResult = result.Result;

            Assert.IsTrue(boolResult);

            var copy = Task.Run(async () => { return await _client.GetAsync<PersonWithAddress>(HashKey0).ConfigureAwait(false); });

            var copyResult = copy.Result;

            Assert.AreEqual(person, copyResult);
        }