Пример #1
0
        public void Count_AfterLazyDeserialization()
        {
            RedisUtility utility = new RedisUtility(Utility.GetDefaultConfigUtility());
            ChangeTrackingSessionStateItemCollection items = Utility.GetChangeTrackingSessionStateItemCollection();

            items.SetDataWithoutUpdatingModifiedKeys("k1", utility.GetBytesFromObject("v1"));
            items.SetDataWithoutUpdatingModifiedKeys("k2", utility.GetBytesFromObject("v2"));

            Assert.Equal(2, items.Count);
            items["k3"] = "v3";
            Assert.Equal(3, items.Count);
        }
Пример #2
0
        public void NullActualValue()
        {
            RedisUtility utility = new RedisUtility(Utility.GetDefaultConfigUtility());
            ChangeTrackingSessionStateItemCollection items = Utility.GetChangeTrackingSessionStateItemCollection();

            items.SetDataWithoutUpdatingModifiedKeys("k1", null);

            Assert.Single(items);
            Assert.Null(items["k1"]);
        }
Пример #3
0
        public void GetEnumerator_AfterLazyDeserialization()
        {
            RedisUtility utility = new RedisUtility(Utility.GetDefaultConfigUtility());
            ChangeTrackingSessionStateItemCollection items = Utility.GetChangeTrackingSessionStateItemCollection();

            items.SetDataWithoutUpdatingModifiedKeys("k1", utility.GetBytesFromObject("v1"));
            items.SetDataWithoutUpdatingModifiedKeys("k2", utility.GetBytesFromObject("v2"));

            try
            {
                foreach (string key in items)
                {
                    // read operation should not change value items.Keys
                    var val = items[key];
                }
            }
            catch (System.InvalidOperationException)
            {
                Assert.False(true, "Reading value from collection should not change it");
            }
        }
Пример #4
0
        public void Dirty_AfterLazyDeserialization()
        {
            RedisUtility utility = new RedisUtility(Utility.GetDefaultConfigUtility());
            ChangeTrackingSessionStateItemCollection items = Utility.GetChangeTrackingSessionStateItemCollection();

            items.SetDataWithoutUpdatingModifiedKeys("Test", utility.GetBytesFromObject("v1"));
            items.Dirty = false;

            Assert.False(items.Dirty);
            // read operation should not change value of Dirty
            var val = items["Test"];

            Assert.False(items.Dirty);

            items["Test"] = "v2";
            Assert.True(items.Dirty);
        }