Exemplo n.º 1
0
        public void ClearTest()
        {
            var dict = new ShieldedDict <string, object>(new KeyValuePair <string, object>[] {
                new KeyValuePair <string, object>("key a", null),
                new KeyValuePair <string, object>("key b", null),
                new KeyValuePair <string, object>("key c", null),
            });

            Assert.Throws <InvalidOperationException>(dict.Clear);

            Shield.InTransaction(() => {
                dict.Clear();
                Assert.AreEqual(0, dict.Count);
                foreach (var kvp in dict)
                {
                    Assert.Fail();
                }
            });
            Assert.AreEqual(0, dict.Count);
            Shield.InTransaction(() => {
                foreach (var kvp in dict)
                {
                    Assert.Fail();
                }
            });
        }
Exemplo n.º 2
0
        public void ClearTest()
        {
            var dict = new ShieldedDict<string, object>(new KeyValuePair<string, object>[] {
                new KeyValuePair<string, object>("key a", null),
                new KeyValuePair<string, object>("key b", null),
                new KeyValuePair<string, object>("key c", null),
            });

            Assert.Throws<InvalidOperationException>(dict.Clear);

            Shield.InTransaction(() => {
                dict.Clear();
                Assert.AreEqual(0, dict.Count);
                foreach (var kvp in dict)
                    Assert.Fail();
            });
            Assert.AreEqual(0, dict.Count);
            Shield.InTransaction(() => {
                foreach (var kvp in dict)
                    Assert.Fail();
            });
        }