public void Clear_EmptyCollection()
 {
     ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();
     Assert.Equal(0, items.Count);
     Assert.Equal(0, items.GetDeletedKeys().Count);
     Assert.Equal(0, items.GetModifiedKeys().Count);
     items.Clear();
     Assert.Equal(0, items.Count);
     Assert.Equal(0, items.GetDeletedKeys().Count);
     Assert.Equal(0, items.GetModifiedKeys().Count);
 }
 public void RemoveAt_Successful()
 {
     ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();
     items["key"] = "value";
     Assert.Equal(1, items.Count);
     Assert.Equal(0, items.GetDeletedKeys().Count);
     Assert.Equal(1, items.GetModifiedKeys().Count);
     items.RemoveAt(0);
     Assert.Equal(0, items.Count);
     Assert.Equal(1, items.GetDeletedKeys().Count);
     Assert.Equal(0, items.GetModifiedKeys().Count);
 }
Example #3
0
        public void RemoveAt_Successful()
        {
            ChangeTrackingSessionStateItemCollection items = Utility.GetChangeTrackingSessionStateItemCollection();

            items["key"] = "value";
            Assert.Equal(1, items.Count);
            Assert.Equal(0, items.GetDeletedKeys().Count);
            Assert.Equal(1, items.GetModifiedKeys().Count);
            items.RemoveAt(0);
            Assert.Equal(0, items.Count);
            Assert.Equal(1, items.GetDeletedKeys().Count);
            Assert.Equal(0, items.GetModifiedKeys().Count);
        }
Example #4
0
        public void Remove_WrongKey()
        {
            ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();

            items["key"] = "value";
            Assert.Equal(1, items.Count);
            Assert.Equal(0, items.GetDeletedKeys().Count);
            Assert.Equal(1, items.GetModifiedKeys().Count);
            items.Remove("key1");
            Assert.Equal(1, items.Count);
            Assert.Equal(0, items.GetDeletedKeys().Count);
            Assert.Equal(1, items.GetModifiedKeys().Count);
        }
 public void Dirty_SetTrue()
 {
     ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();
     items["key1"] = "value1";
     items["key2"] = "value2";
     items["key3"] = "value3";
     Assert.Equal(3, items.Count);
     Assert.Equal(0, items.GetDeletedKeys().Count);
     Assert.Equal(3, items.GetModifiedKeys().Count);
     items.Dirty = true;
     Assert.Equal(3, items.Count);
     Assert.Equal(0, items.GetDeletedKeys().Count);
     Assert.Equal(3, items.GetModifiedKeys().Count);
 }
 public void Clear_Successful()
 {
     ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();
     items["key1"] = "value1";
     items["key2"] = "value2";
     items["key3"] = "value3";
     Assert.Equal(3, items.Count);
     Assert.Equal(0, items.GetDeletedKeys().Count);
     Assert.Equal(3, items.GetModifiedKeys().Count);
     items.Clear();
     Assert.Equal(0, items.Count);
     Assert.Equal(3, items.GetDeletedKeys().Count);
     Assert.Equal(0, items.GetModifiedKeys().Count);
 }
Example #7
0
        public void Clear_Successful()
        {
            ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();

            items["key1"] = "value1";
            items["key2"] = "value2";
            items["key3"] = "value3";
            Assert.Equal(3, items.Count);
            Assert.Equal(0, items.GetDeletedKeys().Count);
            Assert.Equal(3, items.GetModifiedKeys().Count);
            items.Clear();
            Assert.Equal(0, items.Count);
            Assert.Equal(3, items.GetDeletedKeys().Count);
            Assert.Equal(0, items.GetModifiedKeys().Count);
        }
Example #8
0
        public void Dirty_SetFalse()
        {
            ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();

            items["key1"] = "value1";
            items["key2"] = "value2";
            items["key3"] = "value3";
            Assert.Equal(3, items.Count);
            Assert.Equal(0, items.GetDeletedKeys().Count);
            Assert.Equal(3, items.GetModifiedKeys().Count);
            items.Dirty = false;
            Assert.Equal(3, items.Count);
            Assert.Equal(0, items.GetDeletedKeys().Count);
            Assert.Equal(0, items.GetModifiedKeys().Count);
        }
Example #9
0
        public void Dirty_SetTrue()
        {
            ChangeTrackingSessionStateItemCollection items = Utility.GetChangeTrackingSessionStateItemCollection();

            items["key1"] = "value1";
            items["key2"] = "value2";
            items["key3"] = "value3";
            Assert.Equal(3, items.Count);
            Assert.Empty(items.GetDeletedKeys());
            Assert.Equal(3, items.GetModifiedKeys().Count);
            items.Dirty = true;
            Assert.Equal(3, items.Count);
            Assert.Empty(items.GetDeletedKeys());
            Assert.Equal(3, items.GetModifiedKeys().Count);
        }
 public void SetItem_NewItem()
 {
     ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();
     items["key"] = "value";
     items[0] = "value2";
     Assert.Equal(1, items.Count);
     Assert.Equal(1, items.GetModifiedKeys().Count);
 }
Example #11
0
        public void MutableObject_FetchMarksDirty()
        {
            // Initial insert to set up value
            ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();

            items["key1"] = new StringBuilder("value1");
            items.Dirty   = false;
            Assert.Equal(1, items.Count);
            Assert.Equal(false, items.Dirty);
            Assert.Equal(0, items.GetModifiedKeys().Count);
            Assert.Equal(0, items.GetDeletedKeys().Count);

            // update value
            StringBuilder sb = (StringBuilder)items["key1"];

            Assert.Equal(1, items.Count);
            Assert.Equal(1, items.GetModifiedKeys().Count);
        }
Example #12
0
        public void SetItem_NewItem()
        {
            ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();

            items["key"] = "value";
            items[0]     = "value2";
            Assert.Equal(1, items.Count);
            Assert.Equal(1, items.GetModifiedKeys().Count);
        }
Example #13
0
        public void MutableObject_FetchMarksDirty()
        {
            // Initial insert to set up value
            ChangeTrackingSessionStateItemCollection items = Utility.GetChangeTrackingSessionStateItemCollection();

            items["key1"] = new StringBuilder("value1");
            items.Dirty   = false;
            Assert.Single(items);
            Assert.False(items.Dirty);
            Assert.Empty(items.GetModifiedKeys());
            Assert.Empty(items.GetDeletedKeys());

            // update value
            StringBuilder sb = (StringBuilder)items["key1"];

            Assert.Single(items);
            Assert.Single(items.GetModifiedKeys());
        }
 public void RemoveAt_WrongKeyIndex()
 {
     ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();
     items["key"] = "value";
     Assert.Equal(1, items.Count);
     Assert.Equal(0, items.GetDeletedKeys().Count);
     Assert.Equal(1, items.GetModifiedKeys().Count);
     Assert.Throws<ArgumentOutOfRangeException>(() => items.RemoveAt(1));
 }
Example #15
0
        public void RemoveAt_WrongKeyIndex()
        {
            ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();

            items["key"] = "value";
            Assert.Equal(1, items.Count);
            Assert.Equal(0, items.GetDeletedKeys().Count);
            Assert.Equal(1, items.GetModifiedKeys().Count);
            Assert.Throws <ArgumentOutOfRangeException>(() => items.RemoveAt(1));
        }
Example #16
0
        public void RemoveAt_WrongKeyIndex()
        {
            ChangeTrackingSessionStateItemCollection items = Utility.GetChangeTrackingSessionStateItemCollection();

            items["key"] = "value";
            Assert.Single(items);
            Assert.Empty(items.GetDeletedKeys());
            Assert.Single(items.GetModifiedKeys());
            Assert.Throws <ArgumentOutOfRangeException>(() => items.RemoveAt(1));
        }
Example #17
0
        public void SetItem_NewItem()
        {
            ChangeTrackingSessionStateItemCollection items = Utility.GetChangeTrackingSessionStateItemCollection();

            items["key"] = "value";
            items[0]     = "value2";
            Assert.Single(items);
            Assert.Single(items.GetModifiedKeys());
            Assert.Single(items.innerCollection);
        }
Example #18
0
        public void ImmutableObject_FetchDoNotMarksDirty()
        {
            // Initial insert to set up value
            ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();

            items["key1"] = "value1";
            items["key2"] = 10;
            items.Dirty   = false;
            Assert.Equal(2, items.Count);
            Assert.Equal(false, items.Dirty);
            Assert.Equal(0, items.GetModifiedKeys().Count);
            Assert.Equal(0, items.GetDeletedKeys().Count);

            // update value
            string key1 = (string)items["key1"];
            int    key2 = (int)items["key2"];

            Assert.Equal(2, items.Count);
            Assert.Equal(0, items.GetModifiedKeys().Count);
        }
Example #19
0
        public void InsertRemoveUpdate_Sequence()
        {
            // Initial insert to set up value
            ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();

            items["key1"] = "value1";
            Assert.Equal("value1", items[0]);
            Assert.Equal(true, items.Dirty);
            items.Dirty = false;

            // remove key
            items.Remove("key1");
            Assert.Equal(0, items.Count);
            Assert.Equal(1, items.GetDeletedKeys().Count);
            Assert.Equal(0, items.GetModifiedKeys().Count);

            // in same transaction insert same key than it should be update
            items["key1"] = "value1";
            Assert.Equal(1, items.Count);
            Assert.Equal(0, items.GetDeletedKeys().Count);
            Assert.Equal(1, items.GetModifiedKeys().Count);
        }
        public void InsertRemoveUpdate_Sequence()
        {
            // Initial insert to set up value
            ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();
            items["key1"] = "value1";
            Assert.Equal("value1", items[0]);
            Assert.Equal(true, items.Dirty);
            items.Dirty = false;

            // remove key
            items.Remove("key1");
            Assert.Equal(0, items.Count);
            Assert.Equal(1, items.GetDeletedKeys().Count);
            Assert.Equal(0, items.GetModifiedKeys().Count);
            
            // in same transaction insert same key than it should be update
            items["key1"] = "value1";
            Assert.Equal(1, items.Count);
            Assert.Equal(0, items.GetDeletedKeys().Count);
            Assert.Equal(1, items.GetModifiedKeys().Count);
        }
 public void MutableObject_FetchMarksDirty()
 {
     // Initial insert to set up value
     ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();
     items["key1"] = new StringBuilder("value1");
     items.Dirty = false;
     Assert.Equal(1, items.Count);
     Assert.Equal(false, items.Dirty);
     Assert.Equal(0, items.GetModifiedKeys().Count);
     Assert.Equal(0, items.GetDeletedKeys().Count);
     
     // update value 
     StringBuilder sb = (StringBuilder)items["key1"];
     Assert.Equal(1, items.Count);
     Assert.Equal(1, items.GetModifiedKeys().Count);
 }
        public void ImmutableObject_FetchDoNotMarksDirty()
        {
            // Initial insert to set up value
            ChangeTrackingSessionStateItemCollection items = new ChangeTrackingSessionStateItemCollection();
            items["key1"] = "value1";
            items["key2"] = 10;
            items.Dirty = false;
            Assert.Equal(2, items.Count);
            Assert.Equal(false, items.Dirty);
            Assert.Equal(0, items.GetModifiedKeys().Count);
            Assert.Equal(0, items.GetDeletedKeys().Count);

            // update value 
            string key1 = (string) items["key1"];
            int key2 = (int)items["key2"];
            Assert.Equal(2, items.Count);
            Assert.Equal(0, items.GetModifiedKeys().Count);
        }