public void Should_trim_client_id_and_signing_key() { var key = new BusinessKey(" client-id ", " signing-key "); Assert.Equal("client-id", key.ClientId); Assert.Equal("signing-key", key.SigningKey); }
public bool Equals(BusinessKey other) { if (other == null) { return(false); } return(ClientId.Equals(other.ClientId) && SigningKey.Equals(other.SigningKey)); }
public void Should_not_be_equal_with_different_signing_keys() { var key1 = new BusinessKey("client-id", "signing-key1"); var key2 = new BusinessKey("client-id", "signing-key2"); Assert.NotEqual(key1, key2); Assert.NotEqual(key1.GetHashCode(), key2.GetHashCode()); }
public void Should_be_equal_by_value() { var key1 = new BusinessKey("client-id", "signing-key"); var key2 = new BusinessKey("client-id", "signing-key"); Assert.Equal(key1, key2); Assert.Equal(key1.GetHashCode(), key2.GetHashCode()); }
public void Should_generate_signature_from_url() { var key = new BusinessKey("clientID", "vNIXE0xscrmjlyV-12Nj_BvUPaw="); string signedUrl = key.GenerateSignature("http://maps.googleapis.com/maps/api/geocode/json?address=New+York&sensor=false&client=clientID"); Assert.NotNull(signedUrl); Assert.Equal("http://maps.googleapis.com/maps/api/geocode/json?address=New+York&sensor=false&client=clientID&signature=KrU1TzVQM7Ur0i8i7K3huiw3MsA=", signedUrl); }
private HttpRequestMessage BuildWebRequest(string type, string value) { string url = string.Format(ServiceUrl, type, value); if (BusinessKey != null) { url = BusinessKey.GenerateSignature(url); } return(new HttpRequestMessage(HttpMethod.Get, url)); }
private HttpWebRequest BuildWebRequest(string type, string value) { string url = string.Format(ServiceUrl, type, value); if (BusinessKey != null) { url = BusinessKey.GenerateSignature(url); } var req = WebRequest.Create(url) as HttpWebRequest; req.Proxy = Proxy; req.Method = "GET"; return(req); }
public GoogleGeocoder(BusinessKey businessKey) { BusinessKey = businessKey; }
public bool Equals(BusinessKey other) { if (other == null) return false; return ClientId.Equals(other.ClientId) && SigningKey.Equals(other.SigningKey); }
public void Should_trim_and_lower_channel_name(string channel) { var key = new BusinessKey("client-id", "signature", channel); Assert.Equal(channel.Trim().ToLower(), key.Channel); }
public void ServiceUrl_should_contains_channel_name() { var channel = "channel1"; var key = new BusinessKey("client-id", "signature", channel); var geocoder = new GoogleGeocoder(key); Assert.Contains("channel="+channel, geocoder.ServiceUrl); }