public void RejectMalformedVirtualPathTests() { StubDefaultVirtualPathProvider defaultVirtualPathProvider = new StubDefaultVirtualPathProvider(); Assert.False(defaultVirtualPathProvider.IsMalformedVirtualPath("~/a.txt")); Assert.False(defaultVirtualPathProvider.IsMalformedVirtualPath("/a.txt")); Assert.True(defaultVirtualPathProvider.IsMalformedVirtualPath("~/../a.txt")); Assert.True(defaultVirtualPathProvider.IsMalformedVirtualPath("/../a.txt")); Assert.False(defaultVirtualPathProvider.IsMalformedVirtualPath("~/a/../a.txt")); Assert.False(defaultVirtualPathProvider.IsMalformedVirtualPath("/a/../a.txt")); Assert.False(defaultVirtualPathProvider.IsMalformedVirtualPath("~/a/b/../a.txt")); Assert.False(defaultVirtualPathProvider.IsMalformedVirtualPath("/a/b/../a.txt")); Assert.False(defaultVirtualPathProvider.IsMalformedVirtualPath("~/a/b/../../a.txt")); Assert.False(defaultVirtualPathProvider.IsMalformedVirtualPath("/a/b/../../a.txt")); Assert.True(defaultVirtualPathProvider.IsMalformedVirtualPath("~/a/b/../../../a.txt")); Assert.True(defaultVirtualPathProvider.IsMalformedVirtualPath("/a/b/../../../a.txt")); Assert.True(defaultVirtualPathProvider.IsMalformedVirtualPath("~/a/../../b//.txt")); Assert.True(defaultVirtualPathProvider.IsMalformedVirtualPath("/a/../../b//.txt")); }
public void TryFileExistsTest() { StubDefaultVirtualPathProvider defaultVirtualPathProvider = new StubDefaultVirtualPathProvider(); Assert.True(defaultVirtualPathProvider.TryFileExists("~/a.txt")); Assert.False(defaultVirtualPathProvider.TryFileExists("~/../a.txt")); Assert.True(defaultVirtualPathProvider.TryFileExists("~/a/../a.txt")); Assert.True(defaultVirtualPathProvider.TryFileExists("~/a/b/../a.txt")); Assert.True(defaultVirtualPathProvider.TryFileExists("~/a/b/../../a.txt")); Assert.False(defaultVirtualPathProvider.TryFileExists("~/a/b/../../../a.txt")); Assert.False(defaultVirtualPathProvider.TryFileExists("~/a/../../b/c.txt")); }