Skip to content

Commit

Permalink
Merge pull request #12 from caiogranero/fix/gia-code-exception
Browse files Browse the repository at this point in the history
Problemas com CEP sem código GIA
  • Loading branch information
guibranco committed Dec 3, 2019
2 parents 52cdea2 + bf9027e commit 24768d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions ViaCEP.Tests/ZipCodeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,23 @@ public void ValidateSearchByZipCode()
{
var result = ViaCEPClient.Search("03177010");
Assert.NotNull(result);
Assert.Equal("Rua Doutor João Batista de Lacerda", result.Street);
Assert.Equal("Rua Doutor João Batista de Lacerda", result.Street);
Assert.Equal("Quarta Parada", result.Neighborhood);
Assert.Equal("São Paulo", result.City);
Assert.Equal("São Paulo", result.City);
Assert.Equal("SP", result.StateInitials);
}


/// <summary>
/// Validates if the search by zip code don't throw a exception if the address doesn't have a gia code
/// </summary>
/// <returns></returns>
[Fact]
public void ValidateSearchByZipCodeWithoutGiaCode()
{
var result = ViaCEPClient.Search("22795641");
Assert.NotNull(result);
Assert.Null(result.GIACode);
}
}
}
2 changes: 1 addition & 1 deletion ViaCEP/VIaCEPResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ public sealed class ViaCEPResult
/// The gia code.
/// </value>
[JsonProperty("gia")]
public Int32 GIACode { get; set; }
public Int32? GIACode { get; set; }
}
}

0 comments on commit 24768d9

Please sign in to comment.