public async Task GetMessage_Success()
        {
            // Arrange
            var msgId = message.Add(TestInfoMessage, (long)Constants.MessageType.Info);

            // Act
            var msg = await message.Get(msgId);

            // Assert
            Assert.NotNull(msg);
            Assert.IsType <Models.DTOs.Message.Get>(msg);
            Assert.Equal(msg.Text, TestInfoMessage.Text);
            Assert.Equal(msg.Id, msgId);
            Assert.IsType <Models.DTOs.MessageType.Get>(msg.MessageType);
            Assert.Equal(msg.MessageType.Id, (long)Constants.MessageType.Info);
            Assert.Equal(msg.MessageType.Name, Enum.GetName(typeof(Constants.MessageType), (long)Constants.MessageType.Info));
        }
Example #2
0
        public async Task <IHttpActionResult> Get(long?id)
        {
            if (!id.HasValue)
            {
                return(base.ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, Events.MissingParameter.ToString())));
            }

            var task1 = await _message.Get(id.Value);

            if (task1 == null)
            {
                return(base.ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, Events.GetItemNotFound.ToString())));
            }

            return(Ok(task1));
        }