Пример #1
0
        public void IndexingHistory_Update()
        {
            var history = new IndexingHistory();
            var historyAcc = new IndexingHistoryAccessor(history);

            for (int size = 5; size < 20; size += 5)
            {
                historyAcc.Initialize(size);

                Assert.IsTrue(history.Count == 0, string.Format("history.Count is {0}, expected: 0 (size: {1})", history.Count, size));

                history.Add(42, 142);
                history.Add(43, 143);

                for (int i = 1111; i < 1122; i+=2)
                {
                    history.Update(42, i);
                    history.Update(43, i + 1);
                    var value42 = history.Get(42);
                    var value43 = history.Get(43);
                    Assert.IsTrue(value42 == i, string.Format("storage[{0}] is {1}, expected: {2} (size: {3})", 42, value42, i, size));
                    Assert.IsTrue(value43 == i + 1, string.Format("storage[{0}] is {1}, expected: {2} (size: {3})", 43, value43, i + 1, size));
                }

                Assert.IsTrue(history.Count == 2, string.Format("history.Count is {0}, expected: 2 (size: {1})", history.Count, size));
            }
        }
Пример #2
0
 public IndexingHistoryAccessor(IndexingHistory target) : base(target) { }
Пример #3
0
        public void IndexingHistory_Add()
        {
            var history = new IndexingHistory();
            var historyAcc = new IndexingHistoryAccessor(history);

            for (int size = 5; size < 20; size += 5)
            {
                historyAcc.Initialize(size);

                Assert.IsTrue(history.Count == 0, string.Format("history.Count is {0}, expected: 0 (size: {1})", history.Count, size));

                for (int i = 1; i < size + 3; i++)
                    history.Add(i, 100 + i);

                for (int i = 4; i < size + 3; i++)
                {
                    var value = history.Get(i);
                    Assert.IsTrue(value == i + 100, string.Format("storage[{0}] is {1}, expected: {2} (size: {3})", i, value, i + 100, size));
                }

                Assert.IsTrue(history.Count == size, string.Format("history.Count is {0}, expected: {1} (size: {2})", history.Count, size, size));
            }
        }
Пример #4
0
        public void IndexingHistory_ProcessDelete()
        {
            var history = new IndexingHistory();
            var historyAcc = new IndexingHistoryAccessor(history);
            var size = 5;
            historyAcc.Initialize(size);
            Assert.IsTrue(history.Count == 0, string.Format("history.Count is {0}, expected: 0 (size: {1})", history.Count, size));

            history.ProcessDelete(42);
            Assert.IsFalse(history.CheckForAdd(42, 1111), "CheckForAdd(42, 1111) returned with true");
            Assert.IsFalse(history.CheckForUpdate(42, 1112), "CheckForUpdate(42, 1111) returned with true");

            Assert.IsTrue(history.CheckForUpdate(43, 1111), "CheckForAdd(43, 1111) first call returned with false");
            history.ProcessDelete(43);
            Assert.IsFalse(history.CheckForUpdate(43, 1111), "CheckForUpdate(43, 1111) second call returned with true");

            Assert.IsTrue(history.Count == 2, string.Format("history.Count is {0}, expected: 2 (size: {1})", history.Count, size));
        }