public void DeserializeRequest_Null_Message_Throws()
 {
     object[] parameters = new object[] { "hello", 5.0 };
     IDispatchMessageFormatter formatter = new MockHttpMessageFormatter();
     ExceptionAssert.ThrowsArgumentNull(
         "Null message argument should throw",
         "message",
         () =>
         {
             formatter.DeserializeRequest(/*message*/ null, parameters);
         });
 }
 public void DeserializeRequest_Null_Parameters_Throws()
 {
     Message wcfMessage = new HttpRequestMessage().ToMessage();
     IDispatchMessageFormatter formatter = new MockHttpMessageFormatter();
     ExceptionAssert.ThrowsArgumentNull(
          "Null parameters argument should throw",
          "parameters",
          () =>
          {
              formatter.DeserializeRequest(wcfMessage, parameters: null);
          });
 }
 public void DeserializeRequest_Null_HttpRequestMessage_Throws()
 {
     Message wcfMessage = Message.CreateMessage(MessageVersion.None, "unused");
     object[] parameters = new object[] { "hello", 5.0 };
     IDispatchMessageFormatter formatter = new MockHttpMessageFormatter();
     ExceptionAssert.ThrowsInvalidOperation(
         "Non-http message should throw",
         () =>
         {
             formatter.DeserializeRequest(wcfMessage, parameters);
         });
 }
        public void DeserializeRequest_Receives_Message_And_Parameters()
        {
            HttpRequestMessage httpRequestMessage = new HttpRequestMessage();
            Message wcfMessage = httpRequestMessage.ToMessage();
            object[] messageParameters = new object[] { "hello", 5.0 };

            IDispatchMessageFormatter formatter = new MockHttpMessageFormatter()
            {
                OnDeserializeRequest = (msg, parameters) =>
                {
                    Assert.AreSame(httpRequestMessage, msg, "DeserializeRequest did not receive the HttpRequestMessage we specified");
                    Assert.AreSame(messageParameters, parameters, "DeserializeRequest did not receive the parameters we specified");
                }
            };

            formatter.DeserializeRequest(wcfMessage, messageParameters);
            Assert.IsTrue(((MockHttpMessageFormatter)formatter).WasDeserializeRequestCalled, "DeserializeRequest in derived class was not called");
        }