/// <summary>
 /// Retrieve call back URL
 /// </summary>
 /// <param name="panel"></param>
 /// <returns></returns>
 public static string GetCallbackUrl(this UpdatePanelScope panel)
 {
     var ctx = panel.Page.ActionContextsStack().Last();
     var originalUrl = new Uri(ctx.HttpContext.Request.RawUrl, UriKind.Relative);
     var url = originalUrl.ExtendQuery(new Dictionary<string, string> { { UpdatePanelUrlParameterName, panel.Id() } });
     return url.ToString();
 }
		public void TestExtendQuery_empty_dictionary()
		{
			var simpleUri = new Uri("http://dapplo.net");
			var newUri = simpleUri.ExtendQuery(new Dictionary<string, string>());
			Assert.NotNull(newUri);
			Assert.Equal(simpleUri, newUri);
		}
		public void TestExtendQuery_WithDictionary_MultipleValuesInSource()
		{
			var uri = new Uri(TestUriDuplicateValues);
			uri = uri.ExtendQuery(new Dictionary<string, object>
			{
				{
					Key, Value
				}
			});

			Assert.AreEqual($"{TestUriDuplicateValues}&{Key}={Value}", uri.AbsoluteUri);
		}
		public void TestExtendQuery_WithDictionary()
		{
			var uri = new Uri(TestUriSingleValue);
			uri = uri.ExtendQuery(new Dictionary<string, object>
			{
				{
					Key, Value
				}
			});

			Assert.AreEqual($"{TestUriSingleValue}&{Key}={Value}", uri.AbsoluteUri);
		}
		public void TestExtendQuery_WithNameValue()
		{
			var uri = new Uri(TestUriDuplicateValues);
			uri = uri.ExtendQuery(Key, Value);

			Assert.AreEqual($"{TestUriDuplicateValues}&{Key}={Value}", uri.AbsoluteUri);
		}
		public void TestExtendQuery_WithLookup_MultipleValuesInSource()
		{
			var uri = new Uri(TestUriDuplicateValues);
			var testValues = new List<KeyValuePair<string, int>>
			{
				new KeyValuePair<string, int>(Key,Value),
				new KeyValuePair<string, int>(Key,Value),
			};
			var lookup = testValues.ToLookup(x => x.Key, x => x.Value);
			// Make sure we have one Key, which has multiple values
			Assert.IsTrue(lookup.Count() == 1);

			uri = uri.ExtendQuery(lookup);
			Assert.AreEqual($"{TestUriDuplicateValues}&{Key}={Value}&{Key}={Value}", uri.AbsoluteUri);
		}
		public void TestExtendQuery_WithNameValue_EncodingNeeded()
		{
			var uri = new Uri(TestUriDuplicateValues);

			var uriValue = new Uri("http://jira/issue?otherval1=10&othervar2=20");
			var encodedUri = Uri.EscapeDataString(uriValue.AbsoluteUri);

			uri = uri.ExtendQuery("url", uriValue);

			Assert.AreEqual($"{TestUriDuplicateValues}&url={encodedUri}", uri.AbsoluteUri);
		}