public void T2() { var uri = new Uri("http://russia.ru/news/2012/sep/mayor-gets-elected?bonus=true"); var pat = new URIPattern("{year}/{month}/{title}"); var match = pat.MatchURIPath(uri); Assert.IsNull(match); }
public void T6() { var uri = new Uri("http://russia.ru/news/2012/sep/mayor-gets-elected?bonus=true"); var pat = new URIPattern("news/{year}/{month}/{title}/presidential"); var match = pat.MatchURIPath(uri); Aver.IsNull(match); }
public void T11_case_sensitive() { var uri = new Uri("http://russia.ru/news/2012/sep/mayor%2egets%2eelected/"); var pat = new URIPattern("NEWS/{year}/{month}/{title}"); var match = pat.MatchURIPath(uri, senseCase: true); Aver.IsNull(match); }
public void T8() { var uri = new Uri("http://russia.ru/news/2012/sep/mayor-gets-elected/presidential?bonus=true"); var pat = new URIPattern("news/{*path}"); var match = pat.MatchURIPath(uri); Aver.IsNotNull(match); Aver.AreObjectsEqual("2012/sep/mayor-gets-elected/presidential", match["path"]); }
public void MakeURI_T2_params() { var pattern = new URIPattern("{year}/values?{p1}={v1}&par2={v2}"); var map = new JSONDataMap { { "year", "1980" }, { "p1", "par1" }, { "v1", 10 }, { "v2", "val2" } }; var uri = pattern.MakeURI(map); Aver.AreObjectsEqual(new Uri("1980/values?par1%3D10%26par2%3Dval2", UriKind.RelativeOrAbsolute), uri); }
public void MakeURI_T1_noprefix() { var pattern = new URIPattern("/news/{year}/{month}/{title}"); var map = new JSONDataMap { { "year", "1981" }, { "month", 12 }, { "title", "some_title" } }; var uri = pattern.MakeURI(map); Aver.AreObjectsEqual(new Uri("/news/1981/12/some_title", UriKind.RelativeOrAbsolute), uri); }
public void T12_path_with_slashes() { var uri = new Uri("http://contoso.com/news/2012/sep%2fmayor%2egets%2eelected/"); var pat = new URIPattern("news/{year}/{title}"); var match = pat.MatchURIPath(uri); Aver.IsNotNull(match); Aver.AreObjectsEqual("2012", match["year"]); Aver.AreObjectsEqual("sep/mayor.gets.elected", match["title"]); }
public void T5_defaults() { var uri = new Uri("http://russia.ru/news/2012/sep/"); var pat = new URIPattern("news/{year}/{month}/{title=overview}"); var match = pat.MatchURIPath(uri); Aver.IsNotNull(match); Aver.AreObjectsEqual("2012", match["year"]); Aver.AreObjectsEqual("sep", match["month"]); Aver.AreObjectsEqual("overview", match["title"]); }
public void T3_withLeadingSlash() { var uri = new Uri("http://russia.ru/news/2012/sep/mayor-gets-elected?bonus=true"); var pat = new URIPattern("/news/{year}/{month}/{title}"); var match = pat.MatchURIPath(uri); Aver.IsNotNull(match); Aver.AreObjectsEqual("2012", match["year"]); Aver.AreObjectsEqual("sep", match["month"]); Aver.AreObjectsEqual("mayor-gets-elected", match["title"]); }
public void MakeURI_T1_prefix() { var pattern = new URIPattern("{year}/{month}/{title}"); var prefix = new Uri("http://test.com"); var map = new JSONDataMap { { "year", "1981" }, { "month", 12 }, { "title", "some_title" } }; var uri = pattern.MakeURI(map, prefix); Aver.AreObjectsEqual(new Uri(prefix, "http://test.com/1981/12/some_title"), uri); }
public void T11_case_insensitive() { var uri = new Uri("http://russia.ru/news/2012/sep/mayor%2egets%2eelected/"); var pat = new URIPattern("NEWS/{year}/{month}/{title}"); var match = pat.MatchURIPath(uri); Aver.IsNotNull(match); Aver.AreObjectsEqual("2012", match["year"]); Aver.AreObjectsEqual("sep", match["month"]); Aver.AreObjectsEqual("mayor.gets.elected", match["title"]); }
public void T4_defaults() { var uri = new Uri("http://russia.ru/news/2012/sep/mayor-gets-elected?bonus=true"); var pat = new URIPattern("news/{year}/{month}/{title=overview}"); var match = pat.MatchURIPath(uri); Assert.IsNotNull(match); Assert.AreEqual("2012", match["year"]); Assert.AreEqual("sep", match["month"]); Assert.AreEqual("mayor-gets-elected", match["title"]); }
public void MakeURI_T2_params_prefix() { var pattern = new URIPattern("{year}/values?{p1}={v1}&par2={v2}"); var map = new JSONDataMap { { "year", "1980" }, { "p1", "par1" }, { "v1", 10 }, { "v2", "val2" } }; var prefix = new Uri("http://test.org/"); var uri = pattern.MakeURI(map, prefix); Assert.AreEqual(new Uri("http://test.org/1980/values?par1%3D10%26par2%3Dval2", UriKind.RelativeOrAbsolute), uri); }
public void T10_notrailingslash() { var uri = new Uri("http://russia.ru/news/2012/sep/mayor%2egets%2eelected"); var pat = new URIPattern("news/{year}/{month}/{title}"); var match = pat.MatchURIPath(uri); Assert.IsNotNull(match); Assert.AreEqual("2012", match["year"]); Assert.AreEqual("sep", match["month"]); Assert.AreEqual("mayor.gets.elected", match["title"]); }
private void button3_Click(object sender, EventArgs e) { var pat = new URIPattern(tbPattern.Text); var uri = new Uri("http://localhost:8080/cities/cleveland.htm?port=true&law=%2e%2d%56"); // MessageBox.Show(pat._____Chunks); var nu = pat.MakeURI(new Dictionary <string, object> { { "city", "Hamburg" }, { "state", "Ohio" } }, new Uri("http://test.com")); MessageBox.Show(nu.ToString()); // Text = pat.MatchURI( uri )["city"].ToString(); }
public void T9() { var uri = new Uri("http://russia.ru/news/2012/sep/mayor-gets-elected/presidential?bonus=true"); var pat = new URIPattern("news/{*path}/cantbe"); }