示例#1
0
        public void TestGet()
        {
            IDatabase database = connectionRedis.GetDatabase();

            database.Set("customer:" + customer.Id, customer);
            Customer customerGet = database.Get <Customer>("customer:" + customer.Id);

            Assert.AreEqual(customer.ToString(), customerGet.ToString());
        }
示例#2
0
        public void TestHashGet()
        {
            IDatabase database = connectionRedis.GetDatabase();

            database.HashSet("customer", customer.Id.ToString(), customer);
            Customer customerGet = database.HashGet <Customer>("customer", customer.Id.ToString());

            Assert.AreEqual(customer.ToString(), customerGet.ToString());
            database.HashDelete("customer", customer.Id.ToString());
        }
示例#3
0
        public void TestHashGetAll()
        {
            IDatabase database = connectionRedis.GetDatabase();

            database.HashSet("customer", customer.Id.ToString(), customer);
            var      allHashes   = database.HashGetAll <Customer>("customer");
            Customer customerGet = null;

            allHashes.TryGetValue("12", out customerGet);
            Assert.AreEqual(customer.ToString(), customerGet.ToString());
            database.HashDelete("customer", customer.Id.ToString());
        }
示例#4
0
        public void TestGetSet()
        {
            //set Customer
            IDatabase database = connectionRedis.GetDatabase();

            database.Set("customer:" + customer.Id, customer);
            //get Customer
            Customer customerGet = database.Get <Customer>("customer:" + customer.Id);

            Assert.AreEqual(customer.ToString(), customerGet.ToString());
            //create a New Customer
            Customer newCustomer = new Customer();

            newCustomer.Id   = 13;
            newCustomer.Age  = 25;
            newCustomer.Name = "New Customer";
            //set New Customer and get Old Customer
            customerGet = database.GetSet <Customer>("customer:" + customer.Id, newCustomer);
            Assert.AreEqual(customer.ToString(), customerGet.ToString());
            //get New Customer
            customerGet = database.Get <Customer>("customer:" + customer.Id);
            Assert.AreEqual(newCustomer.ToString(), customerGet.ToString());
        }
 public void TestGetSet()
 {
     //set Customer
     IDatabase database = connectionRedis.GetDatabase();
     database.Set("customer:" + customer.Id, customer);
     //get Customer
     Customer customerGet = database.Get<Customer>("customer:" + customer.Id);
     Assert.AreEqual(customer.ToString(), customerGet.ToString());
     //create a New Customer
     Customer newCustomer = new Customer();
     newCustomer.Id = 13;
     newCustomer.Age = 25;
     newCustomer.Name = "New Customer";
     //set New Customer and get Old Customer
     customerGet = database.GetSet<Customer>("customer:" + customer.Id, newCustomer);
     Assert.AreEqual(customer.ToString(), customerGet.ToString());
     //get New Customer
     customerGet = database.Get<Customer>("customer:" + customer.Id);
     Assert.AreEqual(newCustomer.ToString(), customerGet.ToString());
 }