public void WritesLocation() { var writer = new QueryStringOAuthMessageWriter(); var message = new OAuthResponse { LocationUri = "http://mydomain.com" }; var parameters = new Dictionary<string, object> { { "param1", "12345" }, { "param2", 5678 } }; writer.Write(message, parameters); Assert.AreEqual("http://mydomain.com?param1=12345¶m2=5678", message.LocationUri); message = new OAuthResponse { LocationUri = "http://mydomain.com?test=789" }; parameters = new Dictionary<string, object> { { "param1", "12345" }, { "param2", 5678 } }; writer.Write(message, parameters); Assert.AreEqual("http://mydomain.com?test=789¶m1=12345¶m2=5678", message.LocationUri); message = new OAuthResponse { LocationUri = "http://mydomain.com?test=789" }; parameters = new Dictionary<string, object> { { "p aram1", "1 2345" }, { "p aram2", 5678 } }; writer.Write(message, parameters); Assert.AreEqual("http://mydomain.com?test=789&p+aram1=1+2345&p+aram2=5678", message.LocationUri); message = new OAuthResponse { LocationUri = "http://mydomain.com?test=789" }; parameters = new Dictionary<string, object>(); writer.Write(message, parameters); Assert.AreEqual("http://mydomain.com?test=789", message.LocationUri); }
public OAuthRequest BuildQueryMessage() { var message = GetBaseMessage(); var writer = new QueryStringOAuthMessageWriter(); writer.Write(message, _params); return message; }
public void DoesNotWriteEmptyParameters() { var writer = new QueryStringOAuthMessageWriter(); var message = new OAuthResponse { LocationUri = "http://mydomain.com" }; var parameters = new Dictionary<string, object> { { "param1", null }, { "param2", "" } }; writer.Write(message, parameters); Assert.AreEqual("http://mydomain.com", message.LocationUri); message = new OAuthResponse { LocationUri = "http://mydomain.com?test=234" }; parameters = new Dictionary<string, object> { { "param1", null }, { "param2", "" } }; writer.Write(message, parameters); Assert.AreEqual("http://mydomain.com?test=234", message.LocationUri); }
public void WhenParametersIsNull_ThenNothingIsWritten() { var writer = new QueryStringOAuthMessageWriter(); var message = new OAuthResponse { LocationUri = "http://mydomain.com" }; writer.Write(message, null); Assert.AreEqual("http://mydomain.com", message.LocationUri); }
public void IfMessageIsNull_ThenThrowsException() { var writer = new QueryStringOAuthMessageWriter(); writer.Write(null, new Dictionary<string, object>()); }