예제 #1
0
 private void TestReduce(UriToStringDelegate toString, bool testRelative = true, string id = "")
 {
     foreach (var el in reduceElements)
     {
         TestLocations(reduceLocations, el + id, el, toString, testRelative);
     }
 }
예제 #2
0
 private void TestLocations(string [] locations, string id, string str, UriToStringDelegate toString,
                            bool testRelative = true)
 {
     foreach (string location in locations)
     {
         if (location.Contains("{0}"))
         {
             TestLocation(string.Format(location, id), string.Format(location, str), toString, testRelative);
         }
         else
         {
             TestLocation(location + id, location + str, toString, testRelative);
         }
     }
 }
예제 #3
0
        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);
        }
예제 #4
0
        private void TestPercentageEncoding(UriToStringDelegate toString, bool testRelative = false, string id = "")
        {
            TestChars(unescapedStr => {
                var sbUpper = new StringBuilder();
                var sbLower = new StringBuilder();
                foreach (char c in unescapedStr)
                {
                    sbUpper.Append(HexEscapeMultiByte(c, true));
                    sbLower.Append(HexEscapeMultiByte(c, false));
                }
                string escapedUpperStr = sbUpper.ToString();
                string escapedLowerStr = sbLower.ToString();

                TestLocations(componentLocations, unescapedStr + id, unescapedStr, toString, testRelative);
                TestLocations(componentLocations, escapedUpperStr + id + "[Upper]", escapedUpperStr, toString, testRelative);
                TestLocations(componentLocations, escapedLowerStr + id + "[Lower]", escapedLowerStr, toString, testRelative);
            });

            TestLocations(specialCases, id, "", toString, testRelative);
        }
예제 #5
0
		private void TestReduce (UriToStringDelegate toString, bool testRelative = true, string id = "")
		{
			foreach(var el in reduceElements)
				TestLocations (reduceLocations, el + id, el, toString, testRelative);
		}
예제 #6
0
		private void TestPercentageEncoding (UriToStringDelegate toString, bool testRelative = false, string id = "")
		{
			TestChars (unescapedStr => {
				var sbUpper = new StringBuilder ();
				var sbLower = new StringBuilder ();
				foreach (char c in unescapedStr) {
					sbUpper.Append (HexEscapeMultiByte (c, true));
					sbLower.Append (HexEscapeMultiByte (c, false));
				}
				string escapedUpperStr = sbUpper.ToString ();
				string escapedLowerStr = sbLower.ToString ();

				TestLocations (componentLocations, unescapedStr+id, unescapedStr, toString, testRelative);
				TestLocations (componentLocations, escapedUpperStr+id+"[Upper]", escapedUpperStr, toString, testRelative);
				TestLocations (componentLocations, escapedLowerStr+id+"[Lower]", escapedLowerStr, toString, testRelative);
			});

			TestLocations (specialCases, id, "", toString, testRelative);
		}
예제 #7
0
		private void TestLocations (string [] locations, string id, string str, UriToStringDelegate toString,
			bool testRelative = true)
		{
			foreach (string location in locations) {
				if (location.Contains ("{0}"))
					TestLocation (string.Format (location, id), string.Format (location, str), toString, testRelative);
				else
					TestLocation (location + id, location + str, toString, testRelative);
			}
		}
예제 #8
0
		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);
		}