public async Task Usuario_Post_ReturnsBadRequest()
        {
            var request = ServicesUtil.CreateRequestContent(UsuarioFactory.CreateUsuarioEmpty);

            var response = await testContext.Client.PostAsync(endpoint, request);

            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
        }
示例#2
0
        public async Task Login_Post_ReturnsBadRequest()
        {
            var auth = LoginFactory.CreateAuth(string.Empty, string.Empty);

            var request  = ServicesUtil.CreateRequestContent(auth);
            var response = await testContext.Client.PostAsync(endpointLogin, request);

            response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
        }
示例#3
0
        public async Task Usuario_Post_ReturnsOk()
        {
            var request = ServicesUtil.CreateRequestContent(UsuarioFactory.CreateUsuario);

            var response = await testContext.Client.PostAsync(endpoint, request);

            response.StatusCode.Should().Be(HttpStatusCode.OK);

            var message = ServicesUtil.ReadResponseMessage(response);

            message.Should().Be(createUserMessage);
        }
示例#4
0
        public async Task Login_Post_ReturnsInternalServerError()
        {
            var auth = LoginFactory.CreateAuth("usertest", "test123");

            var request  = ServicesUtil.CreateRequestContent(auth);
            var response = await testContext.Client.PostAsync(endpointLogin, request);

            response.StatusCode.Should().Be(HttpStatusCode.InternalServerError);

            var message = ServicesUtil.ReadResponseMessage(response);

            message.Should().Be(errorAccessDenied);
        }
示例#5
0
        public async Task Usuario_Post_ReturnsInternalServerError()
        {
            var request = ServicesUtil.CreateRequestContent(UsuarioFactory.CreateUsuario);

            var responseSuccess = await testContext.Client.PostAsync(endpoint, request);

            responseSuccess.StatusCode.Should().Be(HttpStatusCode.OK);

            var messageSuccess = ServicesUtil.ReadResponseMessage(responseSuccess);

            messageSuccess.Should().Be(createUserMessage);

            var responseError = await testContext.Client.PostAsync(endpoint, request);

            responseError.StatusCode.Should().Be(HttpStatusCode.InternalServerError);

            var messageError = ServicesUtil.ReadResponseMessage(responseError);

            messageError.Should().Be(erroLoginMessage);
        }
示例#6
0
        public async Task Login_Post_ReturnsOk()
        {
            #region Passo 1 -  Criar uma conta de usuário

            var usuario = UsuarioFactory.CreateUsuario;

            var requestCreate  = ServicesUtil.CreateRequestContent(usuario);
            var responseCreate = await testContext.Client.PostAsync(endpointUsuario, requestCreate);

            responseCreate.StatusCode.Should().Be(HttpStatusCode.OK);

            #endregion

            #region Passo 2 - Autenticar o usuário

            var auth = LoginFactory.CreateAuth(usuario.Login, usuario.Senha);

            var requestLogin  = ServicesUtil.CreateRequestContent(auth);
            var responseLogin = await testContext.Client.PostAsync(endpointLogin, requestLogin);

            responseLogin.StatusCode.Should().Be(HttpStatusCode.OK);

            #endregion
        }