Exemplo n.º 1
0
        public void RemoveKey()
        {
            _hashCounter["abc"] = 8;
            _hashCounter["def"] = 150;
            _hashCounter["ghi"] = 25;

            _hashCounter.Remove("abc");
            _hashCounter["def"] = 0;
            _hashCounter.Subtract("ghi", 25);

            using (IEnumerator <KeyValuePair <string, int> > enumerator = _hashCounter.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    switch (enumerator.Current.Key)
                    {
                    case "abc":
                    case "def":
                    case "ghi":
                        Assert.Fail("Removed key present in enumerator.");
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void DoesNotHaveRemovedKeys()
        {
            _hashCounter["abc"] = 8;
            _hashCounter["def"] = 150;
            _hashCounter["ghi"] = 25;

            _hashCounter.Remove("abc");
            _hashCounter["def"] = 0;
            _hashCounter.Subtract("ghi", 25);

            ICollection <string> keys = _hashCounter.Keys;

            Assert.Zero(keys.Count);
        }
Exemplo n.º 3
0
        public void RemovedKey_False()
        {
            _hashCounter["abc"] = 8;
            _hashCounter["def"] = 150;
            _hashCounter["ghi"] = 25;

            _hashCounter.Remove("abc");
            _hashCounter["def"] = 0;
            _hashCounter.Subtract("ghi", 25);

            Assert.False(_hashCounter.Contains("abc"));
            Assert.False(_hashCounter.Contains("def"));
            Assert.False(_hashCounter.Contains("ghi"));
        }