private void TestLocation(string id, string str, UriToStringDelegate toString, bool testRelative = true) { TestScheme(scheme => { string uri = scheme + str; string actual = toString(new Uri(scheme + str, UriKind.Absolute)); StringTester.Assert(scheme + id, actual); }); if (!testRelative) { return; } string relActual = toString(new Uri("./" + str, UriKind.Relative)); StringTester.Assert("./" + id, relActual); }
public void PercentageEncoding_Unescape() { TestChars(str => { var sbUpper = new StringBuilder(); var sbLower = new StringBuilder(); foreach (char c in str) { sbUpper.Append(HexEscapeMultiByte(c, true)); sbLower.Append(HexEscapeMultiByte(c, false)); } string escapedUpperStr = sbUpper.ToString(); string escapedLowerStr = sbLower.ToString(); StringTester.Assert(str + "[Unescaped]", UriEx.UnescapeString("file://a/", str)); StringTester.Assert(escapedUpperStr + "[EscapedUpper]", UriEx.UnescapeString("file://a/", escapedUpperStr)); StringTester.Assert(escapedLowerStr + "[EscapedLower]", UriEx.UnescapeString("file://a/", escapedLowerStr)); }); foreach (var str in specialCases) { StringTester.Assert(str, UriEx.UnescapeString("file://a/", str)); } }
public void Teardown() { StringTester.Save(); }