public void GetMessages_return_correct_message()
        {
            //arrange
            var list = new List <Message>
            {
                new Message()
                {
                    CreatedAt = DateTime.Now - TimeSpan.FromDays(1), Text = "test1"
                },
                new Message()
                {
                    CreatedAt = DateTime.Now, Text = "test2"
                }
            };

            _serv.Setup(x => x.GetMessages()).Returns(list);

            //act
            MessageRepo repo = new MessageRepo(_serv.Object);
            var         res  = repo.GetMessages();

            //assert
            _serv.Verify(f => f.GetMessages(), Times.Once());
            Assert.AreEqual(list.Count, res.Count);
        }
 public HttpResponseMessage GetMessages(long empID)
 {
     try
     {
         return(Request.CreateResponse(HttpStatusCode.OK, _repo.GetMessages(empID)));
     }
     catch (Exception ex)
     {
         return(SetErrorResponse(ex.Message));
     }
 }
        public void GetMessages_return_correct_message()
        {
            //arrange
            var list = new List<Message>
            {
                new Message() {CreatedAt = DateTime.Now - TimeSpan.FromDays(1), Text = "test1"},
                new Message() {CreatedAt = DateTime.Now, Text = "test2"}
            };
            _serv.Setup(x => x.GetMessages()).Returns(list);

            //act
            MessageRepo repo = new MessageRepo(_serv.Object);
            var res = repo.GetMessages();

            //assert
            _serv.Verify(f => f.GetMessages(), Times.Once());
            Assert.AreEqual(list.Count, res.Count);
        }