public void WhenParametersIsNull_ThenNothingIsWritten()
        {
            var writer = new UrlEncodedBodyOAuthMessageWriter();

            var message = new OAuthResponse();

            writer.Write(message, null);

            Assert.AreEqual("", message.Body);
        }
Ejemplo n.º 2
0
        public OAuthResponse BuildBodyMessage()
        {
            var message = GetBaseMessage();

            message.ContentType = ContentType.FormEncoded;
            var writer = new UrlEncodedBodyOAuthMessageWriter();

            writer.Write(message, _parameters);
            return(message);
        }
        public void DoesNotWriteEmptyParameters()
        {
            var writer  = new UrlEncodedBodyOAuthMessageWriter();
            var message = new OAuthResponse();

            var parameters = new Dictionary <string, object> {
                { "param1", null }, { "param2", "" }
            };

            writer.Write(message, parameters);

            Assert.AreEqual(string.Empty, message.Body);
        }
        public void WritesBody()
        {
            var writer  = new UrlEncodedBodyOAuthMessageWriter();
            var message = new OAuthResponse();

            var parameters = new Dictionary <string, object> {
                { "param1", "12345" }, { "param2", 5678 }
            };

            writer.Write(message, parameters);

            Assert.AreEqual("param1=12345&param2=5678", message.Body);

            parameters = new Dictionary <string, object> {
                { "p aram1", "1 2345" }, { "p aram2", 5678 }
            };
            writer.Write(message, parameters);

            Assert.AreEqual("p+aram1=1+2345&p+aram2=5678", message.Body);
        }
        public void IfMessageIsNull_ThenThrowsException()
        {
            var writer = new UrlEncodedBodyOAuthMessageWriter();

            writer.Write(null, new Dictionary <string, object>());
        }