private void HelperTest_Status(CreateDirective directive)
        {
            InitializeTest(out string basePath);
            var filePath = "File1.txt";

            CreateFile(basePath, filePath, directive);

            var replInfo = new ReplInfo(filePath, Roots);

            var status = replInfo.Status();

            if (directive == CreateDirective.OnlyInA || directive == CreateDirective.OnlyInB)
            {
                // File does not exist across all roots
                Assert.AreEqual(ReplicationStatus.IncompleteReplication, status);
            }
            else if (directive == CreateDirective.RootANewer || directive == CreateDirective.RootBNewer)
            {
                // One file n the roots are is more recent
                Assert.AreEqual(ReplicationStatus.WriteDateMismatch, status);
            }
            else if (directive == CreateDirective.SameAge)
            {
                // Replication has completed and the files are the same age
                Assert.AreEqual(ReplicationStatus.Synced, status);
            }
        }
        public void GetFullPath_ImcompleteSync()
        {
            InitializeTest(out string basePath);
            var filePath     = "File1.txt";
            var expectedPath = Path.Combine(Roots[IndexRootB], filePath);

            CreateFile(basePath, filePath, CreateDirective.OnlyInA);

            var replInfo = new ReplInfo(filePath, Roots);

            var path = replInfo.GetFullPath(IndexRootB);

            Assert.AreEqual(expectedPath, path);
        }
        private void HelperTest_Sync(CreateDirective directive)
        {
            InitializeTest(out string basePath);
            var filePath = "File1.txt";

            CreateFile(basePath, filePath, directive);

            var replInfo = new ReplInfo(filePath, Roots);

            var status = replInfo.Sync();

            var aPath = Path.Combine(Roots[IndexRootA], filePath);
            var bPath = Path.Combine(Roots[IndexRootB], filePath);

            switch (directive)
            {
            case CreateDirective.OnlyInA:
                Assert.IsTrue(File.Exists(bPath));
                Assert.AreEqual(December2017, GetLastWriteDate(bPath));
                Assert.AreEqual(ReplicationStatus.Synced, status);
                break;

            case CreateDirective.OnlyInB:
                Assert.IsTrue(File.Exists(aPath));
                Assert.AreEqual(December2017, GetLastWriteDate(aPath));
                Assert.AreEqual(ReplicationStatus.Synced, status);
                break;

            case CreateDirective.RootANewer:
                Assert.IsTrue(File.Exists(bPath));
                Assert.AreEqual(December2017, GetLastWriteDate(bPath));
                Assert.AreEqual(ReplicationStatus.Synced, status);
                break;

            case CreateDirective.RootBNewer:
                Assert.IsTrue(File.Exists(aPath));
                Assert.AreEqual(December2017, GetLastWriteDate(aPath));
                Assert.AreEqual(ReplicationStatus.Synced, status);
                break;

            case CreateDirective.SameAge:
                Assert.AreEqual(ReplicationStatus.Synced, status);
                break;
            }
        }
        private void HelperTest_Constructor(CreateDirective directive)
        {
            InitializeTest(out string basePath);
            var filePath = "File1.txt";

            CreateFile(basePath, filePath, directive);

            var replInfo = new ReplInfo(filePath, Roots);

            // Assert all roots are present
            for (var rootId = 0; rootId < replInfo.Roots.Count; rootId++)
            {
                Assert.AreEqual(Roots[rootId], replInfo.Roots[rootId]);
            }

            // Assert that the Removed flag is false
            Assert.IsFalse(replInfo.Removed);
        }
        private void HelperTest_Remove(CreateDirective directive)
        {
            InitializeTest(out string basePath);
            var filePath = "File1.txt";

            CreateFile(basePath, filePath, directive);

            var replInfo = new ReplInfo(filePath, Roots);

            var aPath = Path.Combine(Roots[IndexRootA], filePath);
            var bPath = Path.Combine(Roots[IndexRootB], filePath);

            var status = replInfo.Remove();

            Assert.AreEqual(ReplicationStatus.Removed, status);
            Assert.IsFalse(File.Exists(aPath));
            Assert.IsFalse(File.Exists(bPath));
        }
        private void HelperTest_GetFileDictionary(CreateDirective directive)
        {
            InitializeTest(out string basePath);
            var filePath = "File1.txt";

            CreateFile(basePath, filePath, directive);

            var replInfo = new ReplInfo(filePath, Roots);

            var files = replInfo.GetFileDictionary();

            if (directive != CreateDirective.OnlyInB)
            {
                Assert.IsNotNull(files[IndexRootA]);
                Assert.AreEqual(files[IndexRootA].Name, filePath);
            }

            if (directive != CreateDirective.OnlyInA)
            {
                Assert.IsNotNull(files[IndexRootB]);
                Assert.AreEqual(files[IndexRootB].Name, filePath);
            }
        }