コード例 #1
0
        public void GetServiceUrl_ServicePrefixWhiteSpaceAllOver()
        {
            System.Uri baseUri = new System.Uri("https://www.cnn.gov");
            IUrlService service = new DefaultUrlService(baseUri, "	api	");

            Assert.AreEqual("https://www.cnn.gov/api/RelativeServicePath/PathAgain", service.GetServiceUrl("RelativeServicePath/PathAgain"), @"
            The GetServiceUrl should take in a path and append the service prefix to the base url, then append
            the path to the result of that.

            All whitespace should be trimmed off of the prefix before it is used.
            ");
        }
コード例 #2
0
        public void GetServiceUrl_ServicePrefixPreceedingSlash()
        {
            System.Uri baseUri = new System.Uri("https://www.cnn.gov");
            IUrlService service = new DefaultUrlService(baseUri, "/api");

            Assert.AreEqual("https://www.cnn.gov/api/RelativeServicePath/PathAgain", service.GetServiceUrl("RelativeServicePath/PathAgain"), @"
            The GetServiceUrl should take in a path and append the service prefix to the base url, then append
            the path to the result of that.

            Having a preceeding slash before the service prefix should not prevent the service from creating
            a valid url.
            ");
        }
コード例 #3
0
        public void GetServiceUrl_ServicePrefixNoPreceedingSlash()
        {
            System.Uri baseUri = new System.Uri("https://www.cnn.gov");
            IUrlService service = new DefaultUrlService(baseUri, "api");

            Assert.AreEqual("https://www.cnn.gov/api/RelativeServicePath/PathAgain", service.GetServiceUrl("RelativeServicePath/PathAgain"), @"
            The GetServiceUrl should take in a path and append the service prefix to the base url, then append
            the path to the result of that.
            ");
        }
コード例 #4
0
        public void GetServiceUrl_ServicePrefixNull()
        {
            System.Uri baseUri = new System.Uri("https://www.cnn.gov");
            IUrlService service = new DefaultUrlService(baseUri, null);

            Assert.AreEqual("https://www.cnn.gov/RelativeServicePath/PathAgain", service.GetServiceUrl("RelativeServicePath/PathAgain"), @"
            The GetServiceUrl should take in a path and append the service prefix to the base url, then append
            the path to the result of that.

            If we pass null in for the service prefix, then it should be ignored.
            ");
        }
コード例 #5
0
        public void GetServiceUrl_PathEmpty()
        {
            System.Uri baseUri = new System.Uri("https://www.cnn.gov");
            IUrlService service = new DefaultUrlService(baseUri, "api");

            Assert.AreEqual("https://www.cnn.gov/api", service.GetServiceUrl(""), @"
            The GetServiceUrl should take in a path and append the service prefix to the base url, then append
            the path to the result of that.

            If the path is empty, then it should be ignored.
            ");
        }