示例#1
0
        public void IndexingHistory_CheckForAdd()
        {
            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));

            Assert.IsTrue(history.CheckForAdd(42, new Timestamps(1111, 1111)), "CheckForAdd(42, 1111) first call returned with false");
            Assert.IsFalse(history.CheckForAdd(42, new Timestamps(1111, 1111)), "CheckForAdd(42, 1111) second call returned with true");
            Assert.IsFalse(history.CheckForAdd(42, new Timestamps(1110, 1110)), "CheckForAdd(42, 1110) returned with true");
            Assert.IsFalse(history.CheckForAdd(42, new Timestamps(1112, 1112)), "CheckForAdd(42, 1112) returned with true");

            Assert.IsTrue(history.CheckForAdd(43, new Timestamps(1111, 1111)), "CheckForAdd(43, 1111) first call returned with false");
            Assert.IsFalse(history.CheckForAdd(43, new Timestamps(1111, 1111)), "CheckForAdd(43, 1111) second call returned with true");
            Assert.IsFalse(history.CheckForAdd(43, new Timestamps(1110, 1110)), "CheckForAdd(43, 1110) returned with true");
            Assert.IsFalse(history.CheckForAdd(43, new Timestamps(1112, 1112)), "CheckForAdd(43, 1112) returned with true");

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

            Assert.IsTrue(history.CheckForAdd(44, new Timestamps(1111, 1111)), "CheckForAdd(44, 1111) returned with false");
            Assert.IsTrue(history.CheckForUpdate(44, new Timestamps(1112, 1112)), "CheckForUpdate(44, 1112) returned with false");
            Assert.IsFalse(history.CheckForAdd(44, new Timestamps(1113, 1113)), "CheckForAdd(44, 1113) rreturned with true");
        }
示例#2
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, new Timestamps(142, 142));
                history.Add(43, new Timestamps(143, 143));

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

                Assert.IsTrue(history.Count == 2, string.Format("history.Count is {0}, expected: 2 (size: {1})", history.Count, size));
            }
        }
示例#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, new Timestamps(100 + i, 100 + i));
                }

                for (int i = 4; i < size + 3; i++)
                {
                    var value = history.Get(i);
                    Assert.IsTrue(value == new Timestamps(100 + i, 100 + i), string.Format("storage[{0}] is {1}, expected: {2} (size: {3})", i, value, new Timestamps(100 + i, 100 + i), 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.IsVersionCanBeAdded(42, new Timestamps(1111, 1111)), "IsVersionCanBeAdded(42, 1111) returned with true");
            Assert.IsFalse(history.IsVersionCanBeUpdated(42, new Timestamps(1112, 1112)), "IsVersionCanBeUpdated(42, 1112) returned with true");

            Assert.IsTrue(history.IsVersionCanBeUpdated(43, new Timestamps(1111, 1111)), "IsVersionCanBeAdded(43, 1111) first call returned with false");
            history.ProcessDelete(43);
            Assert.IsFalse(history.IsVersionCanBeUpdated(43, new Timestamps(1111, 1111)), "IsVersionCanBeUpdated(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));
        }
示例#5
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));
            }
        }
示例#6
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));
            }
        }
示例#7
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));
        }