public void DeleteShouldReturnNotFound()
        {
            var mockCurrentUser = new Mock<ICurrentUser>();
            var mockTodoRepository = new Mock<ITodoRepository>();

            var controller = new TodoController(mockCurrentUser.Object, mockTodoRepository.Object);

            var response = controller.Delete(1);

            Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
        }
        public void DeleteShouldReturnOk()
        {
            var mockCurrentUser = new Mock<ICurrentUser>();
            var mockTodoRepository = new Mock<ITodoRepository>();
            mockTodoRepository
                .Setup(_ => _.GetById(It.IsAny<int>()))
                .Returns(new Todo());

            var controller = new TodoController(mockCurrentUser.Object, mockTodoRepository.Object);

            var response = controller.Delete(1);

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
        }
        public void GetShouldReturnEmptyResult()
        {
            var mockCurrentUser = new Mock<ICurrentUser>();
            mockCurrentUser.Setup(_ => _.UserId).Returns("USERID");

            var mockTodoRepository = new Mock<ITodoRepository>();
            mockTodoRepository.Setup(_ => _.GetAll())
                .Returns(new List<Todo> { new Todo() });

            var controller = new TodoController(mockCurrentUser.Object, mockTodoRepository.Object);

            var result = controller.Get();

            Assert.AreEqual(0, result.Count());
        }
        public void PutShouldReturnNotUnauthorized()
        {
            var mockCurrentUser = new Mock<ICurrentUser>();
            var mockTodoRepository = new Mock<ITodoRepository>();
            mockTodoRepository
               .Setup(_ => _.GetById(It.IsAny<int>()))
               .Returns(new Todo() { UserId = "Some" });

            var controller = new TodoController(mockCurrentUser.Object, mockTodoRepository.Object);

            var response = controller.Put(new Todo());

            Assert.AreEqual(HttpStatusCode.Unauthorized, response.StatusCode);
        }
        public void PostShouldReturnEntity()
        {
            var mockCurrentUser = new Mock<ICurrentUser>();
            mockCurrentUser.Setup(_ => _.UserId).Returns("USERID");

            var mockTodoRepository = new Mock<ITodoRepository>();
            mockTodoRepository.Setup(_ => _.Add(It.IsAny<Todo>())).
                Callback((Todo entity) => entity.Id = 1);

            var controller = new TodoController(mockCurrentUser.Object, mockTodoRepository.Object);

            var todo = controller.Post(new Todo());

            Assert.AreEqual(1, todo.Id);
            Assert.AreEqual("USERID", todo.UserId);
        }