Esempio n. 1
0
        public void Regress_Mutation_ClearReadOnlyData()
        {
            CopyOnWriteHashtable c = new CopyOnWriteHashtable(StringComparer.OrdinalIgnoreCase);

            c["key"] = "value";
            CopyOnWriteHashtable refc = new CopyOnWriteHashtable(c, StringComparer.OrdinalIgnoreCase);

            Assertion.Assert(refc.ContainsKey("key"));
            Assertion.Assert(refc.IsShallowCopy);
            c.Clear();
            Assertion.Assert(refc.ContainsKey("key"));
            Assertion.Assert(!c.ContainsKey("key"));
        }
Esempio n. 2
0
        public void Regress450669_CaseSensitiveBatch_HashtableCopyRespectsComparer()
        {
            Hashtable c = new Hashtable(StringComparer.OrdinalIgnoreCase);

            c["key"] = null;
            CopyOnWriteHashtable refc = new CopyOnWriteHashtable(c, StringComparer.OrdinalIgnoreCase);

            Assertion.Assert(c.ContainsKey("kEy"));
            Assertion.Assert(refc.ContainsKey("kEy"));
        }
Esempio n. 3
0
        public void Regress_SettingWhenValueNull()
        {
            CopyOnWriteHashtable c    = new CopyOnWriteHashtable(StringComparer.OrdinalIgnoreCase);
            CopyOnWriteHashtable refc = new CopyOnWriteHashtable(c, StringComparer.OrdinalIgnoreCase);
            Hashtable            h    = new Hashtable();

            refc["key"] = null;
            h["key"]    = null;

            Assertion.AssertEquals(h.ContainsKey("key"), refc.ContainsKey("key"));
            Assertion.Assert(!c.ContainsKey("key"));
        }
Esempio n. 4
0
        public void Basic()
        {
            CopyOnWriteHashtable c = new CopyOnWriteHashtable(StringComparer.OrdinalIgnoreCase);
            CopyOnWriteHashtable b = (CopyOnWriteHashtable)c.Clone();
            CopyOnWriteHashtable a = (CopyOnWriteHashtable)b.Clone();

            c["Foo"] = "Bar";

            // Just wrote to 'c' so it should contain data.
            Assertion.Assert(c.ContainsKey("Foo"));

            // Writing to a depended upon hashtable should not be visible to the dependents.
            Assertion.Assert(!a.ContainsKey("Foo"));
            Assertion.Assert(!b.ContainsKey("Foo"));
        }