Exemplo n.º 1
0
        public void ShadowGetRelativePath()
        {
            // Arrange
            var path = IOHelper.MapPath("FileSysTests");

            Directory.CreateDirectory(path);
            Directory.CreateDirectory(path + "/ShadowTests");
            Directory.CreateDirectory(path + "/ShadowSystem");

            var fs  = new PhysicalFileSystem(path + "/ShadowTests/", "ignore");
            var sfs = new PhysicalFileSystem(path + "/ShadowSystem/", "ignore");
            var ss  = new ShadowFileSystem(fs, sfs);

            // Act
            File.WriteAllText(path + "/ShadowTests/f1.txt", "foo");
            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes("foo")))
                ss.AddFile("f2.txt", ms);

            // Assert
            var f1RelativePath = ss.GetRelativePath("f1.txt");
            var f2RelativePath = ss.GetRelativePath("f2.txt");

            Assert.AreEqual("f1.txt", f1RelativePath);
            Assert.AreEqual("f2.txt", f2RelativePath);
            Assert.IsTrue(File.Exists(Path.Combine(path, "ShadowTests", "f1.txt")));
            Assert.IsFalse(File.Exists(Path.Combine(path, "ShadowTests", "f2.txt")));
            Assert.IsTrue(File.Exists(Path.Combine(path, "ShadowSystem", "f2.txt")));
            Assert.IsFalse(File.Exists(Path.Combine(path, "ShadowSystem", "f1.txt")));
        }