public void AddFileNamesTest()
        {
            using (var tempDirectory = new TempDirectory(true))
            {
                tempDirectory.AddDirectory("A");

                var manager = new ResultImageManager2(tempDirectory.Name);
                manager.AddFileNames(new []
                {
                    tempDirectory.FullPath(@"A\file0.png"),
                    tempDirectory.FullPath(@"A\file1.png"),
            //					tempDirectory.FullPath(@"file2.png"),
                });

                CollectionAssert.AreEquivalent(new []
                {
                    tempDirectory.FullPath(@"A\file0.png"),
                    tempDirectory.FullPath(@"A\file1.png"),
            //					tempDirectory.FullPath(@"file2.png"),
                }, manager.Files);

            //				Assert.AreEqual(tempDirectory.FullPath(@"file2.png"), manager.GetFile("B"));
                Assert.Null(manager.GetFile("B"));
                Assert.AreEqual(tempDirectory.FullPath(@"A\file0.png"), manager.GetFile("A"));
                Assert.AreEqual(tempDirectory.FullPath(@"A\file1.png"), manager.GetFile("A"));
            }
        }
        public void BackupDirectoryTest()
        {
            using (var dirX = new TempDirectory(true))
            using (var dirY = new TempDirectory(true))
            {
                var t0 = new DateTime(2014, 1, 30, 0, 0, 0); // UTC
                var t1 = t0.AddSeconds(1d);

                {
                    // XとYにあってサイズが違う。
                    var fileA = @"a.txt";
                    dirX.AddFile(fileA, "abc");
                    dirY.AddFile(fileA, "ab");

                    new FileInfo(dirX.FullPath(fileA)).LastWriteTime = t0;
                    new FileInfo(dirY.FullPath(fileA)).LastWriteTime = t0;

                    Assert.AreEqual(new FileInfo(dirX.FullPath(fileA)).LastWriteTime, t0);
                    Assert.AreEqual(new FileInfo(dirX.FullPath(fileA)).LastWriteTime, new FileInfo(dirY.FullPath(fileA)).LastWriteTime);

                    FileAssert.AreNotEqual(dirX.FullPath(fileA), dirY.FullPath(fileA));

                    var backup = new DirectoryBackup(dirX.Name, dirY.Name);
                    backup.Start();

                    FileAssert.AreEqual(dirX.FullPath(fileA), dirY.FullPath(fileA));
                }
                {
                    // XとYにあって更新日時が違う。
                    var fileB = @"s\t\b.txt";
                    dirX.AddFile(fileB, "abc");
                    dirY.AddFile(fileB, "abc");

                    new FileInfo(dirX.FullPath(fileB)).LastWriteTime = t0;
                    new FileInfo(dirY.FullPath(fileB)).LastWriteTime = t1;

                    Assert.AreEqual(new FileInfo(dirX.FullPath(fileB)).LastWriteTime, t0);
                    Assert.AreNotEqual(new FileInfo(dirX.FullPath(fileB)).LastWriteTime, new FileInfo(dirY.FullPath(fileB)).LastWriteTime);

                    var backup = new DirectoryBackup(dirX.Name, dirY.Name);
                    backup.Start();

                    FileAssert.AreEqual(dirX.FullPath(fileB), dirY.FullPath(fileB));
                    Assert.AreEqual(new FileInfo(dirX.FullPath(fileB)).LastWriteTime, new FileInfo(dirY.FullPath(fileB)).LastWriteTime);
                }
                {
                    // XにあってYにない
                    var fileC = @"u\v\c.txt";
                    dirX.AddFile(fileC, "abc");

                    Assert.True(File.Exists(dirX.FullPath(fileC)));
                    Assert.False(File.Exists(dirY.FullPath(fileC)));

                    var backup = new DirectoryBackup(dirX.Name, dirY.Name);
                    backup.Start();

                    Assert.True(File.Exists(dirX.FullPath(fileC)));
                    Assert.True(File.Exists(dirY.FullPath(fileC)));
                }
                {
                    // YにあってXにない
                    var fileD = @"w\x\d.txt";
                    dirY.AddFile(fileD, "abc");

                    Assert.False(File.Exists(dirX.FullPath(fileD)));
                    Assert.True(File.Exists(dirY.FullPath(fileD)));

                    var backup = new DirectoryBackup(dirX.Name, dirY.Name);
                    backup.Start();

                    Assert.False(File.Exists(dirX.FullPath(fileD)));
                    Assert.False(File.Exists(dirY.FullPath(fileD)));
                }
                {
                    // XにあってYにないディレクトリの作成
                    var dir1 = @"xxxx\yyyy";
                    dirX.AddDirectory(dir1);

                    Assert.True(Directory.Exists(dirX.FullPath(dir1)));
                    Assert.False(Directory.Exists(dirY.FullPath(dir1)));

                    var backup = new DirectoryBackup(dirX.Name, dirY.Name);
                    backup.Start();

                    Assert.True(Directory.Exists(dirX.FullPath(dir1)));
                    Assert.True(Directory.Exists(dirY.FullPath(dir1)));
                }
                {
                    // YにあってXにないディレクトリの削除
                    var dir2 = @"ssss\tttt";
                    dirY.AddDirectory(dir2);

                    Assert.False(Directory.Exists(dirX.FullPath(dir2)));
                    Assert.True(Directory.Exists(dirY.FullPath(dir2)));

                    var backup = new DirectoryBackup(dirX.Name, dirY.Name);
                    backup.Start();

                    Assert.False(Directory.Exists(dirX.FullPath(dir2)));
                    Assert.False(Directory.Exists(dirY.FullPath(dir2)));
                }
            }
        }