コード例 #1
0
 /// <inheritdocs/>
 public void CleanSnapshots()
 {
     try
     {
         foreach (var f in _snapMgr.GetPreviousSnapshots())
         {
             File.Delete(f);
         }
     }
     catch (Exception e)
     {
         TheTrace.TraceWarning(e.ToString());
     }
 }
コード例 #2
0
        public void IsCleverInFindingOldSnaps()
        {
            var index = 42L;
            var term  = 2L;

            File.WriteAllText(_mgr.GetTempFileNameForIndexAndTerm(index - 1, term), "");
            File.WriteAllText(_mgr.GetTempFileNameForIndexAndTerm(index + 1, term), "");
            File.WriteAllText(_mgr.GetTempFileNameForIndexAndTerm(index - 2, term), "");
            File.WriteAllText(_mgr.GetFinalFileNameForIndexAndTerm(index, term), "");
            var perv      = _mgr.GetPreviousSnapshots();
            var lastIndex = _mgr.GetLastSnapshot().LastIncludedIndex;

            Assert.Equal(2, perv.Count());
            foreach (var f in perv)
            {
                Assert.True(_mgr.GetSnapshot(f).LastIncludedIndex < index);
            }
        }