Inheritance: Ramone.HyperMedia.SelectableBase, ILinkTemplate
Example #1
0
 protected override void SetUp()
 {
     base.SetUp();
       Url1 = new OpenSearchUrl { RelationType = "tv", MediaType = "text/html", Template = "http://search.com?q={searchTerms}" };
       Url2 = new OpenSearchUrl { RelationType = "home", MediaType = "text/html", Template = "http://search.com?q={searchTerms}" };
       Url3 = new OpenSearchUrl { RelationType = "tv", MediaType = "application/atom+xml", Template = "http://search.com?q={searchTerms}" };
       Url4 = new OpenSearchUrl { RelationType = "home", MediaType = "application/atom+xml", Template = "http://search.com?q={searchTerms}" };
       Urls = new List<OpenSearchUrl>();
       Urls.Add(Url1);
       Urls.Add(Url2);
       Urls.Add(Url3);
       Urls.Add(Url4);
       SearchDescription = new OpenSearchDescription { Urls = Urls };
 }
Example #2
0
        public void CanBindTemplate()
        {
            // Arrange
              ILinkTemplate template = new OpenSearchUrl
                                   {
                                     Template = "http://search.com/?q={terms}",
                                     MediaType = "application/atom+xml",
                                     RelationType = "results"
                                   };

              // Act
              Request request = Session.Bind(template, new { terms = "abc" });

              // Assert
              Assert.IsNotNull(request);
              Assert.AreEqual("http://search.com/?q=abc", request.Url.AbsoluteUri);
        }
        public void CanBindRequestFromLinkTemplateWithoutExplicitSession()
        {
            // Arrange
              string url = ResolveTestUrl(Constants.CatPath).AbsoluteUri;
              ILinkTemplate template = new OpenSearchUrl
              {
            Template = url,
            MediaType = "application/json",
            RelationType = "results"
              };

              // Act
              using (var response = template.Bind(new { name = "Petra" }).AcceptJson().Get<Cat>())
              {
            var body = response.Body;

            // Assert
            Assert.IsNotNull(body);
            Assert.AreEqual("Petra", body.Name);
              }
        }