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();
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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());
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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());
        }