2 using System.Collections.Generic;
3 using System.Diagnostics.Contracts;
6 using Pithos.Interfaces;
8 namespace Pithos.Core.Test
10 public class MockStatusChecker : IStatusChecker, IStatusKeeper
12 public IPithosSettings Settings { get; set; }
14 private readonly string[] _states = { "Normal", "Modified", "Conflict", "Synch" };
16 Dictionary<string, FileOverlayStatus> _overlayCache = new Dictionary<string, FileOverlayStatus>();
17 Dictionary<string, FileStatus> _statusCache = new Dictionary<string, FileStatus>();
18 Dictionary<string, string> _checksums = new Dictionary<string, string>();
20 public FileOverlayStatus GetFileOverlayStatus(string path)
22 Contract.Requires(!String.IsNullOrWhiteSpace(path));
23 if (!_overlayCache.ContainsKey(path))
24 return FileOverlayStatus.NA;
26 var pithosPath = Settings.PithosPath;
27 if (path.StartsWith(pithosPath, true, null))
29 var status = _overlayCache[path];
32 return FileOverlayStatus.NA;
35 public PithosStatus GetPithosStatus()
37 return PithosStatus.InSynch;
40 public void SetFileOverlayStatus(string path, FileOverlayStatus overlayStatus)
42 _overlayCache[path] = overlayStatus;
45 public void RemoveFileOverlayStatus(string path)
47 _overlayCache.Remove(path);
50 public void RenameFileOverlayStatus(string oldPath, string newPath)
52 var status = _overlayCache[oldPath];
53 _overlayCache[newPath] = status;
54 _overlayCache.Remove(oldPath);
57 public void UpdateFileChecksum(string path, string checksum)
59 _checksums[path] = checksum;
62 public void SetFileStatus(string path, FileStatus status)
64 _statusCache[path] = status;
67 public FileStatus GetFileStatus(string path)
69 if (!_statusCache.ContainsKey(path))
70 return FileStatus.Missing;
71 return _statusCache[path];
74 public void ClearFileStatus(string path)
76 _statusCache.Remove(path);