public static AreIdentical ( |
||
left | ||
right | ||
return | bool |
public static bool AreIdentical(Folder left, Folder right)
{
if (left == null || right == null)
{
return false;
}
if (left.Folders.Count != right.Folders.Count)
{
return false;
}
for (int i = 0; i < left.Folders.Count; i++)
{
if (!string.Equals(left.Folders[i].Name, right.Folders[i].Name, System.StringComparison.OrdinalIgnoreCase))
{
return false;
}
if (!AreIdentical(left.Folders[i], right.Folders[i]))
{
return false;
}
}
if (left.Files.Count != right.Files.Count)
{
return false;
}
for (int i = 0; i < left.Files.Count; i++)
{
if (!File.AreIdentical(left.Files[i], right.Files[i]))
{
return false;
}
}
return true;
}
}
private void T(Folder source, Folder destination) { var entrypointDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var root = Path.Combine(entrypointDirectory, nameof(ContentSyncTests)); if (Directory.Exists(root)) { Directory.Delete(root, recursive: true); } Directory.CreateDirectory(root); source.CreateOnDisk(root); destination.CreateOnDisk(root); var sourcePath = Path.Combine(root, source.Name); var destinationPath = Path.Combine(root, destination.Name); Sync.Directories(sourcePath, destinationPath, new Arguments(sourcePath, destinationPath)); var actual = Folder.FromDisk(Path.Combine(root, destination.Name)); var areIdentical = Folder.AreIdentical(source, actual); Assert.True(areIdentical); Directory.Delete(root, recursive: true); }