public void DirectoryExists_PhysicalDirectoryDoesNotExist()
        {
            var provider = new TestableResourceVirtualPathProvider(new[] { new ResourcePathMapping("test", "testResourceFolder") }, _testDirectory);

            provider.SetMakeRelativeVirtualPathOverride((a, b) => "testDirectory");
            provider.SetCombineVirtualPathOverride((a, b) => "~/res/test/");

            Assert.That(provider.DirectoryExists("~/res/test/testDirectory"), Is.False);
        }
        public void DirectoryExists()
        {
            var provider = new TestableResourceVirtualPathProvider(new[] { new ResourcePathMapping("test", "testResourceFolder") }, _testDirectory);

            provider.SetMakeRelativeVirtualPathOverride((a, b) => "subfolder");
            provider.SetCombineVirtualPathOverride((a, b) => "~/res/test/");

            Directory.CreateDirectory(Path.Combine(_testDirectory, "testResourceFolder\\subfolder"));

            Assert.That(provider.DirectoryExists("~/res/test/subfolder"));
        }
        public void FileExists_PhysicalFileDoesNotExist()
        {
            var provider = new TestableResourceVirtualPathProvider(new[] { new ResourcePathMapping("test", "testResourceFolder") }, _testDirectory);

            provider.SetMakeRelativeVirtualPathOverride((a, b) => "testfile.txt");
            provider.SetCombineVirtualPathOverride((a, b) => "~/res/test/");

            Directory.CreateDirectory(Path.Combine(_testDirectory, "testResourceFolder"));

            Assert.That(provider.FileExists("~/res/test/testfile.txt"), Is.False);
        }
        public void FileExists()
        {
            var provider = new TestableResourceVirtualPathProvider(new[] { new ResourcePathMapping("test", "testResourceFolder") }, _testDirectory);

            provider.SetMakeRelativeVirtualPathOverride((a, b) => "testfile.txt");
            provider.SetCombineVirtualPathOverride((a, b) => "~/res/test/");

            Directory.CreateDirectory(Path.Combine(_testDirectory, "testResourceFolder"));
            File.WriteAllText(Path.Combine(_testDirectory, "testResourceFolder\\testfile.txt"), "hello");

            Assert.That(provider.FileExists("~/res/test/testfile.txt"));
        }
        public void GetDirectory()
        {
            var provider = new TestableResourceVirtualPathProvider(new[] { new ResourcePathMapping("test", "testResourceFolder") }, _testDirectory);

            provider.SetMakeRelativeVirtualPathOverride((a, b) => "testDirectory");
            provider.SetCombineVirtualPathOverride((a, b) => "~/res/test/");

            var expectedDirectoryPath = Path.Combine(_testDirectory, "testResourceFolder\\testDirectory");

            Directory.CreateDirectory(expectedDirectoryPath);

            var actual = (ResourceVirtualDirectory)provider.GetDirectory("~/res/test/testDirectory");

            Assert.That(actual.PhysicalPath, Is.EqualTo(expectedDirectoryPath));
            Assert.That(actual.Exists);
        }
        public void GetFile_FileInsideMappedSubdirectory()
        {
            var provider = new TestableResourceVirtualPathProvider(new[] { new ResourcePathMapping("test/subdirectory", "testResourceFolder") }, _testDirectory);

            provider.SetMakeRelativeVirtualPathOverride((a, b) => "testfile.txt");
            provider.SetCombineVirtualPathOverride((a, b) => "~/res/test/subdirectory");

            var expectedFilePath = Path.Combine(_testDirectory, "testResourceFolder\\testfile.txt");

            Directory.CreateDirectory(Path.Combine(_testDirectory, "testResourceFolder"));
            File.WriteAllText(expectedFilePath, "hello");

            var actual = (ResourceVirtualFile)provider.GetFile("~/res/test/subdirectory/testfile.txt");

            Assert.That(actual.PhysicalPath, Is.EqualTo(expectedFilePath));
            Assert.That(actual.Exists);
        }