Ejemplo n.º 1
0
        public void BuildComplexUrl_Get()
        {
            string expected = String.Format("http://testprefix/foo/1/bar/List(foo,2,3)/baz/(deeper:List(found,it,{0}))/biz/123", complexStringEscapedPath);

            GetRequestBuilder <int, Greeting> requestBuilder = new GetRequestBuilder <int, Greeting>("foo/{one}/bar/{list}/baz/{complex}/biz");

            requestBuilder.SetID(123);
            requestBuilder.SetPathKey("one", 1);
            requestBuilder.SetPathKey("list", new List <object>()
            {
                "foo", 2, 3
            });
            requestBuilder.SetPathKey("complex", new Dictionary <string, object>()
            {
                { "deeper", new List <object>()
                  {
                      "found", "it", complexString
                  } }
            });
            GetRequest <int, Greeting> request = requestBuilder.Build();

            RequestUrlBuilder <EntityResponse <Greeting> > urlBuilder = new RequestUrlBuilder <EntityResponse <Greeting> >(request, "http://testprefix");
            Uri url = urlBuilder.Build();

            Assert.AreEqual(expected, url.AbsoluteUri);
        }
        public void SetPathKey()
        {
            GetRequestBuilder <int, Greeting> b = new GetRequestBuilder <int, Greeting>(baseUrl);
            Tone tone = new Tone(Tone.Symbol.FRIENDLY);

            b.SetPathKey("key1", "keyValue1");
            b.SetPathKey("key2", 123);
            b.SetPathKey("key3", tone);
            Assert.AreEqual("keyValue1", b.GetPathKey("key1"));
            Assert.AreEqual(123, b.GetPathKey("key2"));
            Assert.AreEqual(tone.symbol, ((Tone)b.GetPathKey("key3")).symbol);
        }