public void SetUp() { _sliceFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "slice.idx"); _metricsRecorder = new Mock <ISliceIndexMetricsRecorder>(); if (File.Exists(_sliceFilePath)) { File.Delete(_sliceFilePath); } _logIndex = new LogSliceIndex(_sliceFilePath, _metricsRecorder.Object); }
public void When_Starting_Then_IndexIsInitialised() { byte[] key1 = Encoding.UTF8.GetBytes("key1"); byte[] key2 = Encoding.UTF8.GetBytes("key2"); byte[] key3 = Encoding.UTF8.GetBytes("key3"); _logIndex.UpdateIndex(key1, 1); _logIndex.UpdateIndex(key2, 2); _logIndex.UpdateIndex(key3, 3); _logIndex.Close(); _logIndex = new LogSliceIndex(_sliceFilePath, _metricsRecorder.Object); Assert.AreEqual(1, _logIndex.GetSeekPosition(key1)); Assert.AreEqual(2, _logIndex.GetSeekPosition(key2)); Assert.AreEqual(3, _logIndex.GetSeekPosition(key3)); }