コード例 #1
0
        public void WriteWordTest2_Sequential()
        {
            ICacheController <int> cacheController = CreateController();
            int i = 0;

            do
            {
                // write -> read
                string s    = string.Format("1st{0:000}", i);
                Word   word = new Word(i, Convert(s));

                cacheController.WriteWord(i, word);
                Word wordBack = cacheController.ReadWord(i);
                Assert.AreEqual(word.Tag, wordBack.Tag);
                Assert.IsTrue(word.Buffer.SequenceEqual(wordBack.Buffer));

                // update -> read
                s = string.Format("2nd{0:000}", i);
                Word wordSecond = new Word(i, Convert(s));

                cacheController.WriteWord(i, wordSecond);
                Word wordBackSecond = cacheController.ReadWord(i);
                Assert.AreEqual(wordSecond.Tag, wordBackSecond.Tag);
            } while (!databaseStorage_.EOF(++i));
        }
コード例 #2
0
        static void Main(string[] args)
        {
            ICacheController <int> cacheController = CreateController();

            // write -> read
            byte[] bytes42 = Encoding.ASCII.GetBytes("first42");
            byte[] bytes43 = Encoding.ASCII.GetBytes("first43");
            Word   word42  = new Word(42, bytes42);
            Word   word43  = new Word(43, bytes43);

            cacheController.WriteWord(42, word42);
            Word wordBack42 = cacheController.ReadWord(42);

            cacheController.WriteWord(43, word43);
            Word wordBack43 = cacheController.ReadWord(43);

            // update -> read
            byte[] byteSecond42 = Encoding.ASCII.GetBytes("second42");
            byte[] byteSecond43 = Encoding.ASCII.GetBytes("second43");
            Word   wordSecond42 = new Word(42, bytes42);
            Word   wordSecond43 = new Word(43, bytes43);

            cacheController.WriteWord(42, word42);
            Word wordBackSecond42 = cacheController.ReadWord(42);

            cacheController.WriteWord(43, word43);
            Word wordBackSecond43 = cacheController.ReadWord(43);
        }
コード例 #3
0
        public void WriteWordTest1_SelectedTags()
        {
            ICacheController <int> cacheController = CreateController();

            // write -> read
            byte[] bytes42 = Encoding.ASCII.GetBytes("first42");
            byte[] bytes43 = Encoding.ASCII.GetBytes("first43");
            Word   word42  = new Word(42, bytes42);
            Word   word43  = new Word(43, bytes43);

            cacheController.WriteWord(42, word42);
            Word wordBack42 = cacheController.ReadWord(42);

            Assert.AreEqual(word42.Tag, wordBack42.Tag);

            cacheController.WriteWord(43, word43);
            Word wordBack43 = cacheController.ReadWord(43);

            Assert.AreEqual(word43.Tag, wordBack43.Tag);

            // update -> read
            byte[] byteSecond42 = Encoding.ASCII.GetBytes("second42");
            byte[] byteSecond43 = Encoding.ASCII.GetBytes("second43");
            Word   wordSecond42 = new Word(42, bytes42);
            Word   wordSecond43 = new Word(43, bytes43);

            cacheController.WriteWord(42, word42);
            Word wordBackSecond42 = cacheController.ReadWord(42);

            Assert.AreEqual(word42.Tag, wordBackSecond42.Tag);

            cacheController.WriteWord(43, word43);
            Word wordBackSecond43 = cacheController.ReadWord(43);

            Assert.AreEqual(word43.Tag, wordBackSecond43.Tag);
        }