예제 #1
0
        public void GetOrAddTest()
        {
            IWDT iwdt = new IWDT();

            var ret = iwdt.GetOrAdd(HT(1, 1), Tuple.Create(2, 1));

            Assert.AreEqual(Tuple.Create(2, 1), ret);
            Assert.AreEqual(Tuple.Create(2, 1), iwdt.GetItem(HT(1, 1)));

            ret = iwdt.GetOrAdd(HT(1, 1), Tuple.Create(3, 1));

            Assert.AreEqual(Tuple.Create(2, 1), ret);
            Assert.AreEqual(Tuple.Create(2, 1), iwdt.GetItem(HT(1, 2)));

            iwdt.Keys[Tuple.Create(1, 1)].IsGarbage = true;

            ret = iwdt.GetOrAdd(HT(1, 2), Tuple.Create(3, 1));

            Assert.AreEqual(Tuple.Create(3, 1), ret);
            Assert.AreEqual(Tuple.Create(3, 1), iwdt.GetItem(HT(1, 2)));
        }