Ejemplo n.º 1
0
        public async void ShouldSetUser()
        {
            // given
            _toDoRepositoryMock.Setup(r => r.UpdateTodo(toDo1, It.IsAny <ToDo>())).Verifiable();
            // when
            await _toDoService.AssignToUser(toDo1.Id, user.Id);

            // then
            _toDoRepositoryMock.Verify(r => r.UpdateTodo(toDo1, It.IsAny <ToDo>()), Times.Once);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> User(int id, int?userId)
        {
            try
            {
                await _toDoService.AssignToUser(id, userId);

                return(NoContent());
            }
            catch (KeyNotFoundException ex)
            {
                return(NotFound(ex.Message));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(StatusCode(500, "Internal server error"));
            }
        }