コード例 #1
0
        public void AddDataTest()
        {
            TestLruCollection list = new TestLruCollection(4);

            for (int i = 0; i < 5; i++)
            {
                list.Add("S" + i);
            }

            Assert.AreEqual("S4", list[0]);
            Assert.AreEqual("S1", list[3]);
        }
コード例 #2
0
        public void AdvanceAndExceedMaxLengthTest()
        {
            TestLruCollection list = new TestLruCollection(4);

            for (int i = 0; i < 5; i++)
            {
                list.Add("S" + i);
            }

            list.Advance(3);

            Assert.AreEqual("S1", list[0]);
            Assert.AreEqual("S2", list[3]);
        }
コード例 #3
0
        public void AdvanceDataTest()
        {
            TestLruCollection list = new TestLruCollection(4);

            for (int i = 0; i < 4; i++)
            {
                list.Add("S" + i);
            }

            list.Advance(3);

            Assert.AreEqual("S0", list[0]);
            Assert.AreEqual("S1", list[3]);
        }
コード例 #4
0
        public void LruCollectionSerializationText()
        {
            TestLruCollection list = new TestLruCollection(4);

            for (int i = 0; i < 5; i++)
            {
                list.Add("S" + i);
            }

            XElementFormatter formatter = new XElementFormatter();

            XElement root = formatter.Serialize(list);

            Console.WriteLine(root.ToString());

            TestLruCollection deserializedList = (TestLruCollection)formatter.Deserialize(root);

            Assert.AreEqual(list.Count, deserializedList.Count);

            for (int i = 0; i < list.Count; i++)
            {
                Assert.AreEqual(list[i], deserializedList[i]);
            }
        }