public void TestDataReceived() { string url = "http://pastebin.com/raw.php?i=fdHMhAaj"; string dataToSend = String.Empty; string method = "POST"; this.Request = new Correios.Net.Http.Request(url, dataToSend, method, String.Empty); Response response = this.Request.Send(10000); Assert.AreEqual(response.Text, "teste"); }
public void TestConstructorParameters() { string url = "http://www.gooogle.com/"; string dataToSend = "hello=oi"; string method = "POST"; this.Request = new Correios.Net.Http.Request(url, dataToSend, method, String.Empty); Assert.AreEqual(Request.Url, url); Assert.AreEqual(Request.DataToSend, dataToSend); Assert.AreEqual(Request.Method, method); }
/// <summary> /// Realiza a busca do endereço a partir do cep no site dos correios /// </summary> /// <param name="zip">Cep utilizado para busca</param> /// <param name="timeout">Timeout em milisegundos.</param> /// <returns> Address </returns> public static Address GetAddress(string zip, int timeout = 10000) { const string url = "http://m.correios.com.br/movel/buscaCepConfirma.do"; string dataToPost = "cepEntrada=" + zip + "&tipoCep=&cepTemp=&metodo=buscarCep"; const string method = "POST"; const string contentType = "application/x-www-form-urlencoded"; var request = new Request(url, dataToPost, method, contentType); Response response = request.Send(timeout); return response.ToAddress(); }