public async Task ValidaDivisao(int numeroA, int numeroB, int resultadoEsperado) { using var client = new TestClientProvider("Development").Client; var response = await client.GetStringAsync($"/calculos/divide/{numeroA}/{numeroB}"); response.Should().NotBeNull(); response.Should().NotBeEmpty(); response.Should().Be(resultadoEsperado.ToString()); int.Parse(response).Should().BePositive(); }
public async Task ValidaSeTodasAsChamadasDaApiRetornamOContentTypeCerto(string url) { //Preparação using var client = new TestClientProvider("Development").Client; //Ação var response = await client.GetAsync(url); //Afirmação response.EnsureSuccessStatusCode(); Assert.Equal("application/json; charset=utf-8", response.Content.Headers.ContentType.ToString()); }
public async Task ValidaSeTodasAsChamadasDaApiRetornamOContentTypeErrado(string url) { //Arrange using var client = new TestClientProvider("Development").Client; //Act var response = await client.GetAsync(url); //Assert response.EnsureSuccessStatusCode(); Assert.Equal("text/html; charset=utf-8", response.Content.Headers.ContentType.ToString()); }
public async Task ValidaSeOMetodoHttpEstaCorreto(string metodo, int numeroA, int numeroB) { //Arranjo using var client = new TestClientProvider("Development").Client; var request = new HttpRequestMessage(new HttpMethod(metodo), $"calculos/mais/{numeroA}/{numeroB}"); //Ação var response = await client.SendAsync(request); //Afirmação response.EnsureSuccessStatusCode(); Assert.Equal(HttpStatusCode.OK, response.StatusCode); }
public async Task ValidaDivisao(int numeroA, int numeroB, int resultadoEsperado) { //Arrange using var client = new TestClientProvider("Development").Client; //Act var response = await client.GetStringAsync($"/calculos/divide/{numeroA}/{numeroB}"); //Assert Assert.NotNull(response); Assert.IsType <string>(response); Assert.Equal(resultadoEsperado, int.Parse(response)); }
public async Task ValidaSaudeDaApi() { using var client = new TestClientProvider("Development").Client; client.ExecutionTimeOf(obj => obj.GetAsync($"/calculos/saude")).Should().BeLessOrEqualTo(100.Milliseconds()); }