public void PathsCanBeRetrievedByKeyAfterOpen() { var tags = new[] { "alpha", "beta", "charlie", "delta", "echo", "foxtrot", "golf" }; var id = 0; for (var ix = 0; ix < tags.Length; ix++) { id = _cache.AddOrGet(tags.Take(ix + 1)); } var opened = new PathsCache(_tags); _cache.Dispose(); _cache = opened; opened.Open(_path); var path = _cache.Get(id); Assert.That(path, Is.EqualTo(new [] { 2, 3, 4, 5, 6, 7, 8 })); }
public void SetUp() { _folder = new AutoKillFolder("TestPathsCache", true); Directory.CreateDirectory(_folder.Path); _path = Path.Combine(_folder.Path, "test"); _tags = new MockTagsCache(); _cache = new PathsCache(_tags); _cache.Create(_path); _tags.AddOrGet("A"); }
private string LoadPaths(PathsCache cache = null) { if (cache == null) { cache = _cache; } var sb = new StringBuilder(); foreach (var item in cache.Paths) { var itemTags = item .Select(i => _tags.Tags.FirstOrDefault(c => c.Value == i).Key ?? "NULL") .Aggregate((t, i) => t + "," + i); sb.AppendFormat("{0} = {1} [{2}]", item, _cache.AddOrGet(item), itemTags); sb.AppendLine(); } return(sb.ToString()); }
public void PathsAreLoadedOnOpen() { var tags = new[] { "alpha", "beta", "charlie", "delta", "echo", "foxtrot", "golf" }; for (int ix = 0; ix < tags.Length; ix++) { _cache.AddOrGet(tags.Take(ix + 1)); } var opened = new PathsCache(_tags); _cache.Dispose(); _cache = opened; opened.Open(_path); var result = LoadPaths(opened); Console.WriteLine(result); Approvals.Verify(result); }