Ejemplo n.º 1
0
        public void WithSingleQueryString()
        {
            RestUri target = new RestUri("http://localhost/", "account").SetQuery("id", 1);

            var actual = target.ToString();

            Assert.Equal("http://localhost/account?id=1", actual);
        }
Ejemplo n.º 2
0
        public void WithUriTemplateParameter()
        {
            RestUri target = new RestUri("http://localhost/", "account/{id}").SetParameter("id", 1);

            var actual = target.ToString();

            Assert.Equal("http://localhost/account/1", actual);
        }
Ejemplo n.º 3
0
        public void Simple()
        {
            RestUri target = new RestUri("http://localhost/", "account");

            var actual = target.ToString();

            Assert.Equal("http://localhost/account", actual);
        }
Ejemplo n.º 4
0
        public void SimpleWithPathPortionInUrlAndTrailingAndLeadingSlashesInBaseUriAndResourceUrlRespectively()
        {
            RestUri target = new RestUri("http://localhost/api/", "/account");

            var actual = target.ToString();

            Assert.Equal("http://localhost/api/account", actual);
        }
Ejemplo n.º 5
0
        public void SimpleWithPathPortionInUrlAndNoTrailingAndLeadingSlashes()
        {
            RestUri target = new RestUri("http://localhost/api", "account");

            var actual = target.ToString();

            Assert.Equal("http://localhost/api/account", actual);
        }
Ejemplo n.º 6
0
        public void WithUriTemplateParameter()
        {
            RestUri target = new RestUri("http://localhost/", "account/{id}").SetParameter("id", 1);

            var actual = target.ToString();

            Assert.Equal("http://localhost/account/1", actual);
        }
Ejemplo n.º 7
0
        public void SimpleWithPathPortionInUrlAndTrailingAndLeadingSlashesInBaseUriAndResourceUrlRespectively()
        {
            RestUri target = new RestUri("http://localhost/api/", "/account");

            var actual = target.ToString();

            Assert.Equal("http://localhost/api/account", actual);
        }
Ejemplo n.º 8
0
        public void SimpleWithPathPortionInUrlAndNoTrailingAndLeadingSlashes()
        {
            RestUri target = new RestUri("http://localhost/api", "account");

            var actual = target.ToString();

            Assert.Equal("http://localhost/api/account", actual);
        }
Ejemplo n.º 9
0
        public void SimpleWithNonDefaultPort()
        {
            RestUri target = new RestUri("http://localhost:50001/", "account");

            var actual = target.ToString();

            Assert.Equal("http://localhost:50001/account", actual);
        }
Ejemplo n.º 10
0
        public void SimpleWithNonDefaultPort()
        {
            RestUri target = new RestUri("http://localhost:50001/", "account");

            var actual = target.ToString();

            Assert.Equal("http://localhost:50001/account", actual);
        }
Ejemplo n.º 11
0
        public void Simple()
        {
            RestUri target = new RestUri("http://localhost/", "account");

            var actual = target.ToString();

            Assert.Equal("http://localhost/account", actual);
        }
Ejemplo n.º 12
0
        public void WithMultipleUriTemplateParameter()
        {
            RestUri target = new RestUri("http://localhost/", "account/{id}/{uid}/{date}/{email}").SetParameter("id", 1).SetParameter("uid", new Guid("5AAE425D-A603-43B7-86CE-D66EF0AC870C")).SetParameter("date", new DateTime(2010, 1, 1)).SetParameter("email", "*****@*****.**");

            var actual     = target.ToString();
            var dateString = Uri.EscapeDataString(new DateTime(2010, 1, 1).ToString());
            var expected   = string.Format("http://localhost/account/1/5aae425d-a603-43b7-86ce-d66ef0ac870c/{0}/abc%40abc.com", dateString);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 13
0
        public void WithQueryStringRepeatedInBaseUrlAndUsingSetQuery()
        {
            RestUri target = new RestUri("http://localhost/account?id=1").SetQuery("id", 2);

            var actual = target.ToString();

            var expected = "http://localhost/account?id=2";

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 14
0
        public void WithQueryStringNotInNameValueFormatOption3()
        {
            RestUri target = new RestUri("http://localhost/", "account?123456").SetQuery("id", "1");

            var actual = target.ToString();

            var expected = "http://localhost/account?123456&id=1";

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 15
0
        public void WithQueryStringNotInNameValueFormatOption2()
        {
            RestUri target = new RestUri("http://localhost/", "account").SetQuery("123456", QueryStringParameter.None);

            var actual = target.ToString();

            var expected = "http://localhost/account?123456";

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 16
0
        public void WithOnlyQueryStringInResourceUrl()
        {
            RestUri target = new RestUri("http://localhost/account", "?id=1");

            var actual = target.ToString();

            var expected = "http://localhost/account?id=1";

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 17
0
        public void WithEmbededUrlInQueryString()
        {
            RestUri target = new RestUri("http://localhost/account/")
                             .SetQuery("redirectTo", "http://localhost/login");

            var actual = target.ToString();

            var expected = "http://localhost/account?redirectTo=http%3A%2F%2Flocalhost%2Flogin";

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 18
0
        public void WithMultipleQueryStrings()
        {
            RestUri target = new RestUri("http://localhost/", "account").SetQuery("id", 1).SetQuery("date", new DateTime(2010, 1, 1)).SetQuery("uid", new Guid("5AAE425D-A603-43B7-86CE-D66EF0AC870C"));

            var actual = target.ToString();

            var dateString = Uri.EscapeDataString(new DateTime(2010, 1, 1).ToString());
            var expected   = string.Format("http://localhost/account?id=1&date={0}&uid=5aae425d-a603-43b7-86ce-d66ef0ac870c", dateString);

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 19
0
        public void WithEmbededUrlWithPortInUriTemplate()
        {
            RestUri target = new RestUri("http://localhost/account/{redirectTo}")
                             .SetParameter("redirectTo", "http://localhost:80/login");

            var actual = target.ToString();

            var expected = "http://localhost/account/http%3A%2F%2Flocalhost%3A80%2Flogin";

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 20
0
        public void WithEmbededUrlWithPortInUriTemplate()
        {
            RestUri target = new RestUri("http://localhost/account/{redirectTo}")
                .SetParameter("redirectTo", "http://localhost:80/login");

            var actual = target.ToString();

            var expected = "http://localhost/account/http%3A%2F%2Flocalhost%3A80%2Flogin";
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 21
0
        public void WithMultipleUriTemplateParameter()
        {
            RestUri target = new RestUri("http://localhost/", "account/{id}/{uid}/{date}/{email}").SetParameter("id", 1).SetParameter("uid", new Guid("5AAE425D-A603-43B7-86CE-D66EF0AC870C")).SetParameter("date", new DateTime(2010, 1, 1)).SetParameter("email", "*****@*****.**");

            var actual = target.ToString();
            var dateString = Uri.EscapeDataString(new DateTime(2010, 1, 1).ToString());
            var expected = string.Format("http://localhost/account/1/5aae425d-a603-43b7-86ce-d66ef0ac870c/{0}/abc%40abc.com", dateString);
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 22
0
        public void WithQueryStringRepeatedInBaseUrlAndUsingSetQuery()
        {
            RestUri target = new RestUri("http://localhost/account?id=1").SetQuery("id", 2);

            var actual = target.ToString();

            var expected = "http://localhost/account?id=2";
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 23
0
        public void WithQueryStringNotInNameValueFormatOption3()
        {
            RestUri target = new RestUri("http://localhost/", "account?123456").SetQuery("id", "1");

            var actual = target.ToString();

            var expected = "http://localhost/account?123456&id=1";
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 24
0
        public void WithQueryStringNotInNameValueFormatOption2()
        {
            RestUri target = new RestUri("http://localhost/", "account").SetQuery("123456", QueryStringParameter.None);

            var actual = target.ToString();

            var expected = "http://localhost/account?123456";
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 25
0
        public void WithEmbededUrlInQueryString()
        {
            RestUri target = new RestUri("http://localhost/account/")
                .SetQuery("redirectTo", "http://localhost/login");

            var actual = target.ToString();

            var expected = "http://localhost/account?redirectTo=http%3A%2F%2Flocalhost%2Flogin";
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 26
0
        public void WithOnlyQueryStringInResourceUrl()
        {
            RestUri target = new RestUri("http://localhost/account", "?id=1");

            var actual = target.ToString();

            var expected = "http://localhost/account?id=1";
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 27
0
        public void WithSingleQueryString()
        {
            RestUri target = new RestUri("http://localhost/", "account").SetQuery("id", 1);

            var actual = target.ToString();

            Assert.Equal("http://localhost/account?id=1", actual);
        }
Ejemplo n.º 28
0
        public void WithMultipleQueryStrings()
        {
            RestUri target = new RestUri("http://localhost/", "account").SetQuery("id", 1).SetQuery("date", new DateTime(2010, 1, 1)).SetQuery("uid", new Guid("5AAE425D-A603-43B7-86CE-D66EF0AC870C"));

            var actual = target.ToString();

            var dateString = Uri.EscapeDataString(new DateTime(2010, 1, 1).ToString());
            var expected = string.Format("http://localhost/account?id=1&date={0}&uid=5aae425d-a603-43b7-86ce-d66ef0ac870c", dateString);
            Assert.Equal(expected, actual);
        }