コード例 #1
0
        public void When_adding_two_key_objects_which_have_same_hash_verify_that_both_are_added()
        {
            Customer c1 = new Customer {
                Name = "a"
            };
            Customer c2 = new Customer {
                Name = "b"
            };

            _dict.Add(c1, 1);
            _dict.Add(c2, 2);

            Assert.AreEqual(2, _dict.Count);
            Assert.AreEqual(1, _dict[c1]);
            Assert.AreEqual(2, _dict[c2]);
        }
コード例 #2
0
        public void When_adding_key_and_value_with_equal_hash_verify_that_both_are_added()
        {
            Customer c1 = new Customer {
                Name = "a"
            };
            Customer c2 = new Customer {
                Name = "b"
            };

            _dict2.Add(c1, c1);
            _dict2.Add(c2, c2);

            Assert.AreEqual(2, _dict2.Count);
            Assert.AreEqual(c1, _dict2[c1]);
            Assert.AreEqual(c2, _dict2[c2]);
        }
コード例 #3
0
        public void When_deleting_a_key_thrown_KeyNotFoundException_when_accessing_it_afterwards()
        {
            TestFixture t = new TestFixture(10);

            _dict.Add(345, t);
            bool removed = _dict.Remove(345);

            Assert.IsTrue(removed);
            Assert.AreEqual(0, _dict.Count);
            t = _dict[345];
        }