Beispiel #1
0
        public async Task TentandoCriarUsuarioSemEmail()
        {
            Usuario usuario = UsuarioInformacoesTeste.CriandoInformacoesUsuario(false, true, true);

            using (HttpClient client = new ClientProvider().Client)
            {
                HttpResponseMessage response = await client.PostAsync(urlBase, new StringContent(JsonConvert.SerializeObject(usuario), Encoding.UTF8, "application/json"));

                response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
            }
        }
Beispiel #2
0
        public async Task TentandoCriarUsuarioMaxLengthNome()
        {
            Usuario usuario = UsuarioInformacoesTeste.CriandoInformacoesUsuario(true, true, true);

            usuario.Nome = "oefjhoejfwef87w7ef987w1e987f98we7f897we8f4w6e54f65we4f654we68f79we7f98w7e9f87we987f98w7ef987we98f79w8e7f98w7e9f87w9e87f98we7f987we98f79w8e7f98w7ef98we65f4we64f96w8e74f98w7e9f87w98f7w89e4f6we4f98we4f984we9f84w9e8w8e94f98we4f984we98f49w8e4f98w4ef9889we4f9889e";
            using (HttpClient client = new ClientProvider().Client)
            {
                HttpResponseMessage response = await client.PostAsync(urlBase, new StringContent(JsonConvert.SerializeObject(usuario), Encoding.UTF8, "application/json"));

                response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
            }
        }
Beispiel #3
0
        public async Task TentandoCriarUsuarioMaxLengthSenha()
        {
            Usuario usuario = UsuarioInformacoesTeste.CriandoInformacoesUsuario(true, true, true);

            usuario.Senha = "011654se6wergwergerge89r7g98er798g7g98er1";
            using (HttpClient client = new ClientProvider().Client)
            {
                HttpResponseMessage response = await client.PostAsync(urlBase, new StringContent(JsonConvert.SerializeObject(usuario), Encoding.UTF8, "application/json"));

                response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
            }
        }
Beispiel #4
0
        public async Task AlterandoUsuarioComIdErrada()
        {
            Usuario usuario = UsuarioInformacoesTeste.CriandoInformacoesUsuario(true, true, false);

            usuario.Id = 15;
            using (HttpClient client = new ClientProvider().Client)
            {
                HttpResponseMessage response = await client.PutAsync(string.Concat(urlBase, "/10"), new StringContent(JsonConvert.SerializeObject(usuario), Encoding.UTF8, "application/json"));

                response.StatusCode.Should().Be(HttpStatusCode.BadRequest);
            }
        }
Beispiel #5
0
        public async Task InserindoExcluindoUsuario()
        {
            Usuario usuario = UsuarioInformacoesTeste.CriandoInformacoesUsuario(true, true, true);

            using (HttpClient client = new ClientProvider().Client)
            {
                HttpResponseMessage response = await client.PostAsync(string.Concat(urlBase), new StringContent(JsonConvert.SerializeObject(usuario), Encoding.UTF8, "application/json"));

                int id = JsonConvert.DeserializeObject <Usuario>(response.Content.ReadAsStringAsync().Result).Id;
                response.StatusCode.Should().Be(HttpStatusCode.Created);

                response = await client.DeleteAsync(string.Concat(urlBase, "/", id));

                response.StatusCode.Should().Be(HttpStatusCode.OK);
            }
        }
Beispiel #6
0
        public async Task InserindoUsuarioEmailRepetido()
        {
            Usuario usuario = UsuarioInformacoesTeste.CriandoInformacoesUsuario(true, true, true);

            using (HttpClient client = new ClientProvider().Client)
            {
                HttpResponseMessage response = await client.PostAsync(string.Concat(urlBase), new StringContent(JsonConvert.SerializeObject(usuario), Encoding.UTF8, "application/json"));

                int id = JsonConvert.DeserializeObject <Usuario>(response.Content.ReadAsStringAsync().Result).Id;
                response.StatusCode.Should().Be(HttpStatusCode.Created);

                usuario.Nome = "effwefwiwuehfiuwhefiue5fhweiufh89798751000";
                response     = await client.PostAsync(string.Concat(urlBase), new StringContent(JsonConvert.SerializeObject(usuario), Encoding.UTF8, "application/json"));

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

                response = await client.DeleteAsync(string.Concat(urlBase, "/", id));

                response.StatusCode.Should().Be(HttpStatusCode.OK);
            }
        }
Beispiel #7
0
        public async Task AlterandoUsuarioMinLengthNome()
        {
            Usuario usuario = UsuarioInformacoesTeste.CriandoInformacoesUsuario(true, true, true);

            using (HttpClient client = new ClientProvider().Client)
            {
                HttpResponseMessage response = await client.PostAsync(string.Concat(urlBase), new StringContent(JsonConvert.SerializeObject(usuario), Encoding.UTF8, "application/json"));

                usuario.Id = JsonConvert.DeserializeObject <Usuario>(response.Content.ReadAsStringAsync().Result).Id;
                response.StatusCode.Should().Be(HttpStatusCode.Created);

                usuario.Nome = "123";
                HttpResponseMessage responseAlteracao = await client.PutAsync(string.Concat(urlBase, "/", usuario.Id), new StringContent(JsonConvert.SerializeObject(usuario), Encoding.UTF8, "application/json"));

                HttpResponseMessage responseDelete = await client.DeleteAsync(string.Concat(urlBase, "/", usuario.Id));

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

                responseAlteracao.StatusCode.Should().Be(HttpStatusCode.BadRequest);
            }
        }
Beispiel #8
0
        public async Task AlterandoUsuarioMaxLengthNome()
        {
            Usuario usuario = UsuarioInformacoesTeste.CriandoInformacoesUsuario(true, true, true);

            using (HttpClient client = new ClientProvider().Client)
            {
                HttpResponseMessage response = await client.PostAsync(string.Concat(urlBase), new StringContent(JsonConvert.SerializeObject(usuario), Encoding.UTF8, "application/json"));

                usuario.Id = JsonConvert.DeserializeObject <Usuario>(response.Content.ReadAsStringAsync().Result).Id;
                response.StatusCode.Should().Be(HttpStatusCode.Created);

                usuario.Nome = "ergiuherger7g987eg987er9ag49er4g5e4rg654er98g7e98g798e4rg98e4r9ger98g498er4g98er4g4r98g4e98r4g98er4g98e4r89g4e98r4g98er4g98e4r9g84er89g4e+r4g+r4g+r4g9er4g98r4g984er9g49e8r4g984erg984e9r4g98er4g984er9g84r9e84g98er4g984er98g4e98r4g98er4g98r8e4g9e8rg48r4g4reg8";
                HttpResponseMessage responseAlteracao = await client.PutAsync(string.Concat(urlBase, "/", usuario.Id), new StringContent(JsonConvert.SerializeObject(usuario), Encoding.UTF8, "application/json"));

                HttpResponseMessage responseDelete = await client.DeleteAsync(string.Concat(urlBase, "/", usuario.Id));

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

                responseAlteracao.StatusCode.Should().Be(HttpStatusCode.BadRequest);
            }
        }