Exemple #1
0
        public void return_ok_when_todo_is_created()
        {
            createTodoService
            .Setup(x => x.Create(It.IsAny <TodoCreationArgs>()))
            .Returns(ServiceExecutionResult.WithSucess());
            var request = new TodoCreationRequest {
                Title = "title", Description = "simple description"
            };

            var response = controller.Create(request) as OkResult;

            response.StatusCode.ShouldBe((int)HttpStatusCode.OK);
        }
Exemple #2
0
        public void return_bad_request_when_there_are_errors()
        {
            createTodoService
            .Setup(x => x.Create(It.Is <TodoCreationArgs>(x => x.Title == string.Empty)))
            .Returns(ServiceExecutionResult.WithErrors(new List <Error> {
                Error.With(nameof(TodoCreationArgs.Title), ErrorCodes.Required)
            }));
            var request = new TodoCreationRequest {
                Title = string.Empty, Description = "simple description"
            };

            var response = controller.Create(request) as BadRequestObjectResult;

            response.StatusCode.ShouldBe((int)HttpStatusCode.BadRequest);
        }