public void CreateCombinedUrlShouldSucceedForFileFormat() { string baseUrl = "file://levelup"; string addendum = "blah.txt"; string expectedCombination = "file://levelup/blah.txt"; Assert.AreEqual(RestSharpUtils.CreateCombinedUrl(baseUrl, addendum), expectedCombination); }
public void CreateCombinedUrlShouldFailForInvalidFormat() { string baseUrl = "levelup"; string addendum = @"\blah"; Assert.Throws <UriFormatException>(() => { RestSharpUtils.CreateCombinedUrl(baseUrl, addendum); }); }
public void CreateCombinedUrlShouldSucceed() { string baseUrlWithTrailingSlash = "http://test.thelevelup.com/"; string baseUrlWithOutTrailingSlash = "http://test.thelevelup.com"; string addendumWithLeadingSlash = "/blah"; string addendumWithoutLeadingSlash = "blah"; string expectedCombination = "http://test.thelevelup.com/blah"; Assert.AreEqual(RestSharpUtils.CreateCombinedUrl(baseUrlWithTrailingSlash, addendumWithLeadingSlash), expectedCombination); Assert.AreEqual(RestSharpUtils.CreateCombinedUrl(baseUrlWithTrailingSlash, addendumWithoutLeadingSlash), expectedCombination); Assert.AreEqual(RestSharpUtils.CreateCombinedUrl(baseUrlWithOutTrailingSlash, addendumWithLeadingSlash), expectedCombination); Assert.AreEqual(RestSharpUtils.CreateCombinedUrl(baseUrlWithOutTrailingSlash, addendumWithoutLeadingSlash), expectedCombination); }
public void BuildRequestShouldSucceed() { const string body = "{{\"access_token\": {{\"api_key\": \"my_key\",\"username\": \"my_username\",\"password\": \"my_password\"}}}}"; const string bodyType = "application/json"; var headers = new Dictionary <string, string>(); headers.Add("Authorization", "auth_value"); headers.Add("Accept", bodyType); IRestRequest request = RestSharpUtils.BuildRequest(Method.GET, headers, null, body, RestSharpUtils.ContentType.Json); foreach (var pair in headers) { Assert.AreEqual(request.Parameters.First(x => x.Name == pair.Key).Value, pair.Value); } Assert.AreEqual(request.Parameters.First(x => x.Name == bodyType).Value, body); }