Example #1
0
 public void ShouldExpandListAndVariableWithSizeLimiteInPathSegment()
 {
     UriTemplate template = new UriTemplate("{/list*,path:4}");
     string result = template.Expand(new
     {
         list = new string[] { "red", "green", "blue" },
         path = "/foo/bar"
     });
     Assert.AreEqual("/red/green/blue/%2Ffoo", result);
 }
Example #2
0
 public void ShouldExpandPairsWhenReservedAllowed()
 {
     UriTemplate template = new UriTemplate("{+keys}");
     string result = template.Expand(new
     {
         keys = new
         {
             semi = ";",
             dot = ".",
             comma = ","
         }
     });
     Assert.AreEqual("semi,;,dot,.,comma,,", result);
 }
Example #3
0
 public void ShouldHandleMultipleSubstitutions1()
 {
     UriTemplate template = new UriTemplate("http://localhost{+port}/api{/version}/customers{?q,pagenum,pagesize}{#section}");
     string uri = template.Expand(new
     {
         port = ":8080",
         version = "v2",
         q = "rest",
         pagenum = 3,
         pagesize = (int?)null,
         section = "results"
     });
     Assert.AreEqual("http://localhost:8080/api/v2/customers?q=rest&pagenum=3&pagesize=#results", uri);
 }
Example #4
0
 public void ShouldExpandListWhenExplodedInFragmentExpansion()
 {
     UriTemplate template = new UriTemplate("{#list*}");
     string result = template.Expand(new { list = new string[] { "red", "green", "blue" } });
     Assert.AreEqual("#red,green,blue", result);
 }
Example #5
0
 public void ShouldExpandVariableWithSmallerSizeLimitInLabelExpansion()
 {
     UriTemplate template = new UriTemplate("X{.var:3}");
     string result = template.Expand(new { var = "value" });
     Assert.AreEqual("X.val", result);
 }
Example #6
0
 public void ShouldExpandVariableWithSizeLimitSmallerThanValueInQueryContinuation()
 {
     UriTemplate template = new UriTemplate("{&var:3}");
     string result = template.Expand(new { var = "value" });
     Assert.AreEqual("&var=val", result);
 }
Example #7
0
 public void ShouldExpandVariableWithSizeLimitSmallerThanValueForPathStyleParameters()
 {
     UriTemplate template = new UriTemplate("{;hello:5}");
     string result = template.Expand(new { hello = "Hello World!" });
     Assert.AreEqual(";hello=Hello", result);
 }
Example #8
0
 public void ShouldExpandListWhenExplodedForPathStyleParameters()
 {
     UriTemplate template = new UriTemplate("{;list*}");
     string result = template.Expand(new { list = new string[] { "red", "green", "blue" } });
     Assert.AreEqual(";list=red;list=green;list=blue", result);
 }
Example #9
0
 public void ShouldExpandVariablesInQuery()
 {
     UriTemplate template = new UriTemplate("{?x,y}");
     string result = template.Expand(new { x = 1024, y = 768 });
     Assert.AreEqual("?x=1024&y=768", result);
 }
Example #10
0
 public void ShouldExpandVariablesInPathSegment()
 {
     UriTemplate template = new UriTemplate("{/var,x}/here");
     string result = template.Expand(new { var = "value", x = 1024 });
     Assert.AreEqual("/value/1024/here", result);
 }
Example #11
0
 public void ShouldExpandVariablesInLabelExpansion()
 {
     UriTemplate template = new UriTemplate("X{.x,y}");
     string result = template.Expand(new { x = 1024, y = 768 });
     Assert.AreEqual("X.1024.768", result);
 }
Example #12
0
 public void ShouldExpandVariables()
 {
     UriTemplate template = new UriTemplate("map?{x,y}");
     string result = template.Expand(new { x = "1024", y = "768" });
     Assert.AreEqual("map?1024,768", result);
 }
Example #13
0
 public void ShouldExpandVariableInPathSegment()
 {
     UriTemplate template = new UriTemplate("{/var}");
     string result = template.Expand(new { var = "value" });
     Assert.AreEqual("/value", result);
 }
Example #14
0
 public void ShouldExpandVariableInLabelExpansion()
 {
     UriTemplate template = new UriTemplate("X{.var}");
     string result = template.Expand(new { var = "value" });
     Assert.AreEqual("X.value", result);
 }
Example #15
0
 public void ShouldExpandListInQueryContinuation()
 {
     UriTemplate template = new UriTemplate("{&list}");
     string result = template.Expand(new { list = new string[] { "red", "green", "blue" } });
     Assert.AreEqual("&list=red,green,blue", result);
 }
Example #16
0
 public void ShouldExpandVariableWhenReservedAllowed()
 {
     UriTemplate template = new UriTemplate("{+var}");
     string result = template.Expand(new { var = "value" });
     Assert.AreEqual("value", result);
 }
Example #17
0
 public void ShouldExpandVariableWithReservedCharacterInFragmentExpansion()
 {
     UriTemplate template = new UriTemplate("X{#hello}");
     string result = template.Expand(new { hello = "Hello World!" });
     Assert.AreEqual("X#Hello+World!", result);
 }
Example #18
0
 public void ShouldExpandVariablesInQueryContinuation()
 {
     UriTemplate template = new UriTemplate("?fixed=yes{&x}");
     string result = template.Expand(new { x = 1024 });
     Assert.AreEqual("?fixed=yes&x=1024", result);
 }
Example #19
0
 public void ShouldExpandVariableWithSizeLimitGreaterThanValue()
 {
     UriTemplate template = new UriTemplate("{var:30}");
     string result = template.Expand(new { var = "value" });
     Assert.AreEqual("value", result);
 }
Example #20
0
 public void ShouldExpandVariablesWithEmptyForPathStyleParameters()
 {
     UriTemplate template = new UriTemplate("{;x,y,empty}");
     string result = template.Expand(new { x = 1024, y = 768, empty = "" });
     Assert.AreEqual(";x=1024;y=768;empty", result);
 }
Example #21
0
 public void ShouldExpandVariableWithSizeLimitSmallerThanValueInPathSegment()
 {
     UriTemplate template = new UriTemplate("{/var:1,var}");
     string result = template.Expand(new { var = "value" });
     Assert.AreEqual("/v/value", result);
 }
Example #22
0
 public void ShouldExpandListWhenExploded()
 {
     UriTemplate template = new UriTemplate("{list*}");
     string result = template.Expand(new { list = new List<string>() { "red", "green", "blue" } });
     Assert.AreEqual("red,green,blue", result);
 }
Example #23
0
 public void ShouldExpandVariableWithSmallerSizeLimitInFragmentExpansion()
 {
     UriTemplate template = new UriTemplate("{#path:6}/here");
     string result = template.Expand(new { path = "/foo/bar" });
     Assert.AreEqual("#/foo/b/here", result);
 }
Example #24
0
 public void ShouldExpandVariablesWithEmptyInQueryContinuation()
 {
     UriTemplate template = new UriTemplate("{&x,y,empty}");
     string result = template.Expand(new { x = 1024, y = 768, empty = "" });
     Assert.AreEqual("&x=1024&y=768&empty=", result);
 }
Example #25
0
 public void ShouldExpandVariableWithSmallerSizeLimitWhenReservedAllowed()
 {
     UriTemplate template = new UriTemplate("{+path:6}/here");
     string result = template.Expand(new { path = "/foo/bar" });
     Assert.AreEqual("/foo/b/here", result);
 }
Example #26
0
 public void ShouldExpandVariablesWithReservedCharacters()
 {
     UriTemplate template = new UriTemplate("{x,hello,y}");
     string result = template.Expand(new { x = "1024", hello = "Hello World!", y = 768 });
     Assert.AreEqual("1024,Hello+World!,768", result);
 }
Example #27
0
 public void ShouldExpandVariableWithSpaceWhenReservedAllowed()
 {
     UriTemplate template = new UriTemplate("{+hello}");
     string result = template.Expand(new { hello = "Hello, World!" });
     Assert.AreEqual("Hello,+World!", result);
 }
Example #28
0
 public void ShouldExpandVariablesWithSlashWhenReservedAllowedInFragmentExpansion()
 {
     UriTemplate template = new UriTemplate("{#path,x}/here");
     string result = template.Expand(new { x = 1024, path = "/foo/bar", y = 768 });
     Assert.AreEqual("#/foo/bar,1024/here", result);
 }
Example #29
0
 public void ShouldExpandListWhenExplodedInLabelExpansion()
 {
     UriTemplate template = new UriTemplate("X{.list*}");
     string result = template.Expand(new { list = new string[] { "red", "green", "blue" } });
     Assert.AreEqual("X.red.green.blue", result);
 }
Example #30
0
 public void ShouldExpandVariablesWithSpaceWhenReservedAllowedInFragmentExpansion()
 {
     UriTemplate template = new UriTemplate("{#x,hello,y}");
     string result = template.Expand(new { x = 1024, hello = "Hello World!", y = 768 });
     Assert.AreEqual("#1024,Hello+World!,768", result);
 }