예제 #1
0
        public void TestMethod1()
        {
            string constUri         = "http://beyova.com/";
            string constUriWithPath = "http://beyova.com/test";

            UriEndpoint endpoint = new UriEndpoint
            {
                Protocol = "http",
                Host     = "beyova.com",
                Path     = null
            };

            Assert.AreEqual(constUri, endpoint.ToString());

            UriEndpoint endpoint2 = new Uri(constUri);

            Assert.AreEqual(endpoint, endpoint2);

            UriEndpoint endpoint3 = new UriEndpoint
            {
                Protocol = "http",
                Host     = "beyova.com",
                Path     = "test"
            };

            Assert.AreEqual(constUriWithPath, endpoint3.ToString());

            UriEndpoint endpoint4 = new Uri(constUriWithPath);

            Assert.AreEqual(endpoint3, endpoint4);
        }
        /// <summary>
        /// Gets the request endpoint.
        /// </summary>
        /// <param name="apiEndpoint">The API endpoint.</param>
        /// <param name="realm">The realm.</param>
        /// <param name="version">The version.</param>
        /// <returns>System.String.</returns>
        protected internal static string GetRequestEndpoint(UriEndpoint apiEndpoint, string realm, string version)
        {
            var pathPrefix = string.IsNullOrWhiteSpace(realm) ? "/api/" : string.Format("/{0}/api/", realm.Trim());

            return(string.Format("{0}{1}{2}/", (apiEndpoint ?? new UriEndpoint()).GetBaseUri(), pathPrefix, version));
        }