Added several utils and tests that I often use.
    public class ScopeDictionaryTests
    {
        const string A = "A";

        const string E = "E";
        const string F = "F";
        const string G = "G";

        const string Scope1 = "Scope1";
        const string Scope2 = "Scope2";
        const string Scope3 = "Scope3";

        [TestMethod]
        public void ScopeDictionary_Tests()
        {
            var sd = new ScopeDictionary<string, string>();

            Assert.AreEqual(0, sd.ScopeDepth);
            Assert.AreEqual(0, sd.Count);
            Assert.AreEqual(0, sd.CountAllScopes);

            sd.Add(A, Scope1);
            sd.Add(B, Scope1);
            sd.Add(C, Scope1);

            Action checkScope1 = () =>
            {
                Assert.AreEqual(0, sd.ScopeDepth);
                Assert.AreEqual(3, sd.CountAllScopes);
                Assert.AreEqual(3, sd.Count);
                CollectionAssert.AreEqual(new string[] { A, B, C }, sd.Keys.ToArray());
                CollectionAssert.AreEqual(new string[] { A, B, C }, sd.KeysAllScopes.ToArray());
                CollectionAssert.AreEqual(new string[] { Scope1, Scope1, Scope1 }, sd.ValuesAllScopes.ToArray());

                Assert.IsTrue(sd.ContainsKey(A));
                Assert.IsTrue(sd.ContainsKey(B));
                Assert.IsTrue(sd.ContainsKey(C));
                Assert.IsFalse(sd.ContainsKey(D));
                Assert.IsFalse(sd.ContainsKey(E));
                Assert.IsFalse(sd.ContainsKey(F));
                Assert.IsFalse(sd.ContainsKey(G));

                Assert.IsTrue(sd.ContainsKeyAnyScope(A));
                Assert.IsTrue(sd.ContainsKeyAnyScope(B));
                Assert.IsTrue(sd.ContainsKeyAnyScope(C));
                Assert.IsFalse(sd.ContainsKeyAnyScope(D));
                Assert.IsFalse(sd.ContainsKeyAnyScope(E));
                Assert.IsFalse(sd.ContainsKeyAnyScope(F));
                Assert.IsFalse(sd.ContainsKeyAnyScope(G));
            };

            checkScope1();

            sd.PushScope();

            sd.Add(A, Scope2);
            sd.Add(C, Scope2);
            sd.Add(D, Scope2);

            Action checkScope2 = () =>
            {
                Assert.AreEqual(1, sd.ScopeDepth);
                Assert.AreEqual(4, sd.CountAllScopes);
                Assert.AreEqual(3, sd.Count);
                CollectionAssert.AreEqual(new string[] { A, C, D, B }, sd.KeysAllScopes.ToArray());
                CollectionAssert.AreEqual(new string[] { A, C, D }, sd.Keys.ToArray());
                CollectionAssert.AreEqual(new string[] { Scope2, Scope2, Scope2, Scope1 }, sd.ValuesAllScopes.ToArray());

                Assert.IsTrue(sd.ContainsKey(A));
                Assert.IsFalse(sd.ContainsKey(B));
                Assert.IsTrue(sd.ContainsKey(C));
                Assert.IsTrue(sd.ContainsKey(D));
                Assert.IsFalse(sd.ContainsKey(E));
                Assert.IsFalse(sd.ContainsKey(F));
                Assert.IsFalse(sd.ContainsKey(G));

                Assert.IsTrue(sd.ContainsKeyAnyScope(A));
                Assert.IsTrue(sd.ContainsKeyAnyScope(B));
                Assert.IsTrue(sd.ContainsKeyAnyScope(C));
                Assert.IsTrue(sd.ContainsKeyAnyScope(D));
                Assert.IsFalse(sd.ContainsKeyAnyScope(E));
                Assert.IsFalse(sd.ContainsKeyAnyScope(F));
                Assert.IsFalse(sd.ContainsKeyAnyScope(G));
            };

            checkScope2();

            sd.PushScope();

            sd.Add(E, Scope3);
            sd.Add(F, Scope3);
            sd.Add(G, Scope3);
            sd.Add(A, Scope3);

            Assert.AreEqual(2, sd.ScopeDepth);
            Assert.AreEqual(7, sd.CountAllScopes);
            Assert.AreEqual(4, sd.Count);
            CollectionAssert.AreEqual(new string[] { E, F, G, A, C, D, B }, sd.KeysAllScopes.ToArray());
            CollectionAssert.AreEqual(new string[] { E, F, G, A }, sd.Keys.ToArray());
            CollectionAssert.AreEqual(new string[] { Scope3, Scope3, Scope3, Scope3, Scope2, Scope2, Scope1 }, sd.ValuesAllScopes.ToArray());

            Assert.IsTrue(sd.ContainsKey(A));
            Assert.IsFalse(sd.ContainsKey(B));
            Assert.IsFalse(sd.ContainsKey(C));
            Assert.IsFalse(sd.ContainsKey(D));
            Assert.IsTrue(sd.ContainsKey(E));
            Assert.IsTrue(sd.ContainsKey(F));
            Assert.IsTrue(sd.ContainsKey(G));

            Assert.IsTrue(sd.ContainsKeyAnyScope(A));
            Assert.IsTrue(sd.ContainsKeyAnyScope(B));
            Assert.IsTrue(sd.ContainsKeyAnyScope(C));
            Assert.IsTrue(sd.ContainsKeyAnyScope(D));
            Assert.IsTrue(sd.ContainsKeyAnyScope(E));
            Assert.IsTrue(sd.ContainsKeyAnyScope(F));
            Assert.IsTrue(sd.ContainsKeyAnyScope(G));

            sd.PopScope();

            checkScope2();

            sd.PopScope();

            checkScope1();
        }

    }
Version Update