コード例 #1
0
        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);
        }
コード例 #2
0
        public void FileExists_NotMappedDirectory_FallsBackToPreviousProvider()
        {
            var previousProviderStub = MockRepository.GenerateStub <VirtualPathProvider>();
            var provider             = new TestableResourceVirtualPathProvider(new[] { new ResourcePathMapping("test", "testResourceFolder") }, _testDirectory);

            provider.SetPrevious(previousProviderStub);

            previousProviderStub.Stub(_ => _.FileExists("~/res/UnknownDirectory/testfile.txt")).Return(true);

            Assert.That(provider.FileExists("~/res/UnknownDirectory/testfile.txt"), Is.True);
        }
コード例 #3
0
        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"));
        }