Skip to content

Commit

Permalink
Merge pull request #73 from guibranco/feature/linter
Browse files Browse the repository at this point in the history
Linter
  • Loading branch information
guibranco committed Jul 28, 2023
2 parents 7a56cc7 + 2d985cd commit 22198b4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ foreach(var result in results){

## Changelog

* 2023-07-28: Add integration tests [#71](https://github.com/guibranco/ViaCEP/issues/71) by [@Riju-bak](https://github.com/Riju-bak)
* 2023-03-03: Update dependencies, change branch name, update logo. [@guibranco](https://github.com/guibranco)
* 2021-06-21: Update dependencies version. [@guibranco](https://github.com/guibranco)
* 2020-10-23: Add support to .NET Standard 2.0 and .NET Framework v4.6.1 and above. [@guibranco](https://github.com/guibranco)
22 changes: 18 additions & 4 deletions Tests/ViaCep.IntegrationTests/AddressTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public async Task Search_WithValidAddress_ReturnsExpectedResult()
var validZipCodeTwo = "01002-000"; //Another valid zip code for the same city and state

//Act
var results = (await Client.SearchAsync(validState, validCity, validAddress, default)).ToList();
var results = (
await Client.SearchAsync(validState, validCity, validAddress, default)
).ToList();

//Assert
Assert.NotNull(results);
Expand All @@ -31,7 +33,12 @@ public async Task Search_WithNonexistentAddress_ReturnsEmptyResults()
var nonExistentCity = "Non-existent City";

//Act
var results = await Client.SearchAsync("XX", nonExistentCity, nonExistentAddress, default);
var results = await Client.SearchAsync(
"XX",
nonExistentCity,
nonExistentAddress,
default
);

//Assert
Assert.Empty(results);
Expand All @@ -48,8 +55,15 @@ public async Task Search_WithCanceledToken_ThrowsTaskCanceledException()
cancellationTokenSource.Cancel();

//Act and Assert
await Assert.ThrowsAsync<TaskCanceledException>(() =>
Client.SearchAsync(validState, validCity, validAddress, cancellationTokenSource.Token));
await Assert.ThrowsAsync<TaskCanceledException>(
() =>
Client.SearchAsync(
validState,
validCity,
validAddress,
cancellationTokenSource.Token
)
);
}
}
}
9 changes: 6 additions & 3 deletions Tests/ViaCep.IntegrationTests/ZipCodeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public async Task Search_WithInvalidZipCode_ThrowsHttpRequestException()
var invalidZipCode = "invalid";

//Act and Assert
await Assert.ThrowsAsync<HttpRequestException>(() => Client.SearchAsync(invalidZipCode, default));
await Assert.ThrowsAsync<HttpRequestException>(
() => Client.SearchAsync(invalidZipCode, default)
);
}

[Fact]
Expand All @@ -38,8 +40,9 @@ public async Task Search_WithCanceledToken_ThrowsTaskCanceledException()
cancellationTokenSource.Cancel();

//Act and Assert
await Assert.ThrowsAsync<TaskCanceledException>(() =>
Client.SearchAsync("01001-000", cancellationTokenSource.Token));
await Assert.ThrowsAsync<TaskCanceledException>(
() => Client.SearchAsync("01001-000", cancellationTokenSource.Token)
);
}
}
}

0 comments on commit 22198b4

Please sign in to comment.