Esempio n. 1
0
 private void TestReduce(UriToStringDelegate toString, bool testRelative = true, string id = "")
 {
     foreach (var el in reduceElements)
     {
         TestLocations(reduceLocations, el + id, el, toString, testRelative);
     }
 }
Esempio n. 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);
         }
     }
 }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 5
0
		private void TestReduce (UriToStringDelegate toString, bool testRelative = true, string id = "")
		{
			foreach(var el in reduceElements)
				TestLocations (reduceLocations, el + id, el, toString, testRelative);
		}
Esempio n. 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);
		}
Esempio n. 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);
			}
		}
Esempio n. 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);
		}