예제 #1
0
 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));
 }
예제 #2
0
        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);
        }
예제 #3
0
        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();