public HttpResponseMessage postMessage([FromBody] loggingMessage msg) { if (msg.msg == null) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Please submit a message value")); } sharedActions.writeMessage("Message:" + msg.msg + "\r\n Sender:" + msg.sender); return(Request.CreateResponse(HttpStatusCode.OK, msg)); }
public void PostLoggingMessageBadRequest() { var controller = new LoggingController { Request = new System.Net.Http.HttpRequestMessage(), Configuration = new HttpConfiguration() }; loggingMessage testMsg = new loggingMessage(); testMsg.sender = "Doc Brown"; HttpResponseMessage result = controller.postMessage(testMsg); Assert.AreEqual(System.Net.HttpStatusCode.BadRequest, result.StatusCode); Assert.AreEqual("Please submit a message value", result.Content.ReadAsAsync <HttpError>().Result.Message); }
public void PostLoggingMessageOK() { var controller = new LoggingController { Request = new System.Net.Http.HttpRequestMessage(), Configuration = new HttpConfiguration() }; loggingMessage testMsg = new loggingMessage(); testMsg.msg = "Howdy world!!"; HttpResponseMessage result = controller.postMessage(testMsg); var resultText = result.Content as ObjectContent; Assert.AreEqual(System.Net.HttpStatusCode.OK, result.StatusCode); Assert.AreEqual(testMsg, resultText.Value); }
var(loggingEventId, loggingException, loggingMessage, loggingFormatArguments) = loggingPreprocess();