Esempio n. 1
0
        private string ResolveMatchedPath(FilePatternMatch matchedPath)
        {
            // Resolve the path to site root
            var relativePath = new PathString("/" + matchedPath.Path);

            return(RequestPathBase.Add(relativePath).ToString());
        }
        public void TestGetHashCodeWithNull()
        {
            FilePatternMatch match = new FilePatternMatch(null, null);

            Assert.Equal(0, match.GetHashCode());

            int hash1 = new FilePatternMatch("non null", null).GetHashCode();
            int hash2 = new FilePatternMatch(null, "non null").GetHashCode();

            Assert.NotEqual(0, hash1);
            Assert.NotEqual(0, hash2);
            Assert.NotEqual(hash1, hash2);
        }
        public void TestGetHashCode()
        {
            FilePatternMatch match1 = new FilePatternMatch("sub/sub2/bar/baz/three.txt", "sub2/bar/baz/three.txt");
            FilePatternMatch match2 = new FilePatternMatch("sub/sub2/bar/baz/three.txt", "sub2/bar/baz/three.txt");
            FilePatternMatch match3 = new FilePatternMatch("sub/sub2/bar/baz/one.txt", "sub2/bar/baz/three.txt");
            FilePatternMatch match4 = new FilePatternMatch("sub/sub2/bar/baz/three.txt", "sub2/bar/baz/one.txt");

            Assert.Equal(match1.GetHashCode(), match2.GetHashCode());
            Assert.NotEqual(match1.GetHashCode(), match3.GetHashCode());
            Assert.NotEqual(match1.GetHashCode(), match4.GetHashCode());

            // FilePatternMatch is case insensitive
            FilePatternMatch matchCase1 = new FilePatternMatch("Sub/Sub2/bar/baz/three.txt", "sub2/bar/baz/three.txt");
            FilePatternMatch matchCase2 = new FilePatternMatch("sub/sub2/bar/baz/three.txt", "Sub2/bar/baz/thrEE.txt");

            Assert.Equal(matchCase1.GetHashCode(), matchCase2.GetHashCode());
        }