public async System.Threading.Tasks.Task Valida_get_count() { var mockHttp = new MockHttpMessageHandler(); var jsonMock = ApiProductTest.Properties.Resources.JsonMockServicosBancarios; var url = ""; // Setup a respond for the user api (including a wildcard in the URL) mockHttp.When("https://olinda.bcb.gov.br/olinda/servico/Informes_ListaValoresDeServicoBancario/versao/v1/odata/*") .Respond("application/json", jsonMock); // Respond with JSON // Inject the handler or client into your application code var client = mockHttp.ToHttpClient(); var dadosRetorno = await ServicoBancarioService.RetornaServicosBancariosGet(url, client); //var servicosBanc = JsonConvert.DeserializeObject<Root>(dadosRetorno); //var response = await client.GetAsync(""); // or without async: var response = client.GetAsync("http://localhost/api/user/1234").Result; //var json = await response.Content.ReadAsStringAsync(); Assert.AreEqual(servicosBanc.value.Count, 2); //Assert.AreEqual(json, jsonMock); }
public List <Value> Get(int id) { var url = "https://olinda.bcb.gov.br/olinda/servico/Informes_ListaValoresDeServicoBancario/versao/v1/odata/GruposConsolidados?%24format=json&%24top=100"; HttpClient client = new HttpClient(); var dados = ServicoBancarioService.RetornaServicosBancariosGet(url, client).Result; var servicosBanc = JsonConvert.DeserializeObject <Root>(dados); return(servicosBanc.value); }