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. "); }
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. "); }
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. "); }
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. "); }
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. "); }