This repository has been archived by the owner on May 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
686d884
commit 0f2245e
Showing
5 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using NUnit.Framework; | ||
|
||
namespace DotCEP.Test | ||
{ | ||
[TestFixture] | ||
public class TestConsultas | ||
{ | ||
[Test] | ||
public void TestConsultaEnderecoCompletoValido() | ||
{ | ||
DotCEP.Endereco enderecoBase = DotCEP.Consultas.ObterEnderecoCompleto("96085000"); | ||
|
||
Assert.AreEqual("Pelotas", enderecoBase.localidade); | ||
Assert.AreEqual("Areal", enderecoBase.bairro); | ||
Assert.AreEqual("Avenida Ferreira Viana", enderecoBase.logradouro); | ||
} | ||
|
||
[Test] | ||
public void TestConsultaEnderecoCompletoInvalido() | ||
{ | ||
DotCEP.Endereco enderecoBase = DotCEP.Consultas.ObterEnderecoCompleto("960850000"); | ||
|
||
Assert.AreEqual(null, enderecoBase.localidade); | ||
Assert.AreEqual(null, enderecoBase.bairro); | ||
Assert.AreEqual(null, enderecoBase.logradouro); | ||
} | ||
|
||
[Test] | ||
public void TestConsultaListaEnderecos() | ||
{ | ||
System.Collections.Generic.List<Endereco> ListaEnderecos = DotCEP.Consultas.ObterListaDeEnderecos(UF.RS, "Pelotas", "Ferreira"); | ||
|
||
Assert.AreEqual(11, ListaEnderecos.Count); | ||
Assert.AreEqual("Três Vendas", ListaEnderecos[6].bairro); | ||
} | ||
|
||
[TearDown] | ||
public void ApagarCache() | ||
{ | ||
Spartacus.Database.Generic database = new Spartacus.Database.Sqlite(ObterCaminhoBancoCache()); | ||
Spartacus.Database.Command cmd = new Spartacus.Database.Command(); | ||
|
||
cmd.v_text = "Delete from Cache"; | ||
database.Execute(cmd.GetUpdatedText()); | ||
|
||
cmd.v_text = "Delete from ConsultaEndereco"; | ||
database.Execute(cmd.GetUpdatedText()); | ||
} | ||
|
||
private static string ObterCaminhoBancoCache() | ||
{ | ||
if (((int)Environment.OSVersion.Platform) < 4) | ||
{ | ||
return string.Format(@"{0}\\Cache\\Cache.db", System.AppDomain.CurrentDomain.BaseDirectory); // Windows | ||
} | ||
else | ||
{ | ||
return String.Format(@"{0}/Cache/Cache.db", System.AppDomain.CurrentDomain.BaseDirectory); // Linux e MacOSX | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="NUnit" version="3.5.0" targetFramework="net45" /> | ||
<package id="Spartacus" version="0.42.0" targetFramework="net45" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters