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)); } }
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)); } }