Skip to content

Commit 9ad75dd

Browse files
authored
Merge pull request #44 from danilolutz/release/v1.1.2
Release/v1.1.2
2 parents a6c3bd0 + f332476 commit 9ad75dd

14 files changed

Lines changed: 113 additions & 108 deletions

File tree

.github/CODE_OF_CONDUCT.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
The CoreZipCode code of conduct is derived from the Ruby code of conduct. Any violations of the code of conduct may be reported to Danilo Lutz (danilolutz@gmail.com).
44

55
- Participants will be tolerant of opposing views.
6-
76
- Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
8-
97
- When interpreting the words and actions of others, participants should always assume good intentions.
10-
11-
- Behavior which can be reasonably considered harassment will not be tolerated.
8+
- Behavior which can be reasonably considered harassment will not be tolerated.

.github/CONTRIBUTING.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ However, if you prefer to work with code, simply go to [Cloning the repository](
1717

1818
We follow (or try to) this code architecture principles:
1919

20-
* [OOP](https://en.wikipedia.org/wiki/Object-oriented_programming)
21-
* [SOLID](https://en.wikipedia.org/wiki/SOLID)
22-
* [Design Patterns](https://en.wikipedia.org/wiki/Software_design_pattern)
23-
* [DRY - Don't Repeat Yourself](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself)
24-
* [KISS - Keep It Simple, Stupid](https://en.wikipedia.org/wiki/KISS_principle)
25-
* [YAGNI - You Aren't Gonna Need It](https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it)
20+
- [OOP](https://en.wikipedia.org/wiki/Object-oriented_programming)
21+
- [SOLID](https://en.wikipedia.org/wiki/SOLID)
22+
- [Design Patterns](https://en.wikipedia.org/wiki/Software_design_pattern)
23+
- [DRY - Don't Repeat Yourself](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself)
24+
- [KISS - Keep It Simple, Stupid](https://en.wikipedia.org/wiki/KISS_principle)
25+
- [YAGNI - You Aren't Gonna Need It](https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it)
2626

2727
## Reporting an Issue
2828

@@ -64,16 +64,16 @@ Maybe you ask yourself: _How can I contribute?_ or _What i can do?_
6464

6565
We'll help you:
6666

67-
* You can implement you favorite zipcode or postcode service and submit to CoreZipCode to be an out-of-the-box service;
68-
* You can find and fix bugs;
69-
* Implement openned issues;
70-
* Improve the CoreZipCode programming.
67+
- You can implement you favorite zipcode or postcode service and submit to CoreZipCode to be an out-of-the-box service;
68+
- You can find and fix bugs;
69+
- Implement openned issues;
70+
- Improve the CoreZipCode programming.
7171

7272
**Only thing will be required by us to approve the pull requests are the unit tests (with correct code coverage) for the new implementations**.
7373

7474
## Testing
7575

76-
You already know how it's works, just add you test class in ```CoreZipCode.Tests``` project, implement it, run the unit tests, be sure everything is okay and submit to repo.
76+
You already know how it's works, just add you test class in `CoreZipCode.Tests` project, implement it, run the unit tests, be sure everything is okay and submit to repo.
7777

7878
To run the tests go to solution folder and execute:
7979

@@ -88,6 +88,7 @@ dotnet test CoreZipCode.Tests/CoreZipCode.Tests.csproj -p:CollectCoverage=true -
8888

8989
reportgenerator -reports:CoreZipCode.Tests/.coverage/coverage.opencover.xml -targetdir:CoreZipCode.Tests/.coverage
9090
```
91+
9192
And open the file `CoreZipCode.Tests/.coverage/index.htm` to see how the unit tests are affecting the code coverage.
9293

9394
> **NOTE**: You need to have [ReportGenerator](https://www.nuget.org/packages/dotnet-reportgenerator-globaltool) installed. Use the follow command: `dotnet tool install -g dotnet-reportgenerator-globaltool` to install it globally.

CoreZipCode.Tests/Services/Interfaces/ApiHandlerTest.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,30 @@
1010

1111
namespace CoreZipCode.Tests.Services.Interfaces
1212
{
13-
public class ApiHandlerTest
13+
public static class ApiHandlerTest
1414
{
15-
private Mock<HttpMessageHandler> _handlerMock;
1615
private const string SendAsync = "SendAsync";
1716
private const string MockUri = "https://unit.test.com/";
1817

19-
private HttpClient ConfigureService(HttpStatusCode statusCode)
18+
private static HttpClient ConfigureService(HttpStatusCode statusCode)
2019
{
21-
_handlerMock = new Mock<HttpMessageHandler>();
20+
var handlerMock = new Mock<HttpMessageHandler>();
2221

23-
_handlerMock
22+
handlerMock
2423
.Protected()
2524
.Setup<Task<HttpResponseMessage>>(
2625
SendAsync,
2726
ItExpr.IsAny<HttpRequestMessage>(),
2827
ItExpr.IsAny<CancellationToken>()
2928
)
30-
.ReturnsAsync(new HttpResponseMessage()
29+
.ReturnsAsync(new HttpResponseMessage
3130
{
3231
StatusCode = statusCode,
3332
Content = new StringContent(""),
3433
})
3534
.Verifiable();
3635

37-
var httpClient = new HttpClient(_handlerMock.Object)
36+
var httpClient = new HttpClient(handlerMock.Object)
3837
{
3938
BaseAddress = new Uri(MockUri),
4039
};
@@ -43,7 +42,7 @@ private HttpClient ConfigureService(HttpStatusCode statusCode)
4342
}
4443

4544
[Fact]
46-
public void MustCreateANewInstance()
45+
public static void MustCreateANewInstance()
4746
{
4847
var apiHandler = new ApiHandler();
4948
var apiHandlerWithHttpClient = new ApiHandler(ConfigureService(HttpStatusCode.OK));
@@ -53,19 +52,19 @@ public void MustCreateANewInstance()
5352
}
5453

5554
[Fact]
56-
public void MustCallApiException()
55+
public static void MustCallApiException()
5756
{
5857
var apiHandler = new ApiHandler(ConfigureService(HttpStatusCode.BadRequest));
5958

60-
Assert.Throws<Exception>(() => apiHandler.CallApi(MockUri));
59+
Assert.Throws<HttpRequestException>(() => apiHandler.CallApi(MockUri));
6160
}
6261

6362
[Fact]
64-
public async void MustCallApiAsyncException()
63+
public static async Task MustCallApiAsyncException()
6564
{
6665
var apiHandler = new ApiHandler(ConfigureService(HttpStatusCode.BadRequest));
6766

68-
await Assert.ThrowsAsync<Exception>(() => apiHandler.CallApiAsync(MockUri));
67+
await Assert.ThrowsAsync<HttpRequestException>(() => apiHandler.CallApiAsync(MockUri));
6968
}
7069
}
7170
}

CoreZipCode.Tests/Services/Postcode/PostalpincodeInApi/PostalpincodeInTest.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,32 @@ public class PostalpincodeInTest
2020
private const string SendAsync = "SendAsync";
2121
private const string MockUri = "https://unit.test.com/";
2222

23-
private Mock<HttpMessageHandler> _handlerMock;
2423
private readonly PostalpincodeIn _service;
2524

2625
public PostalpincodeInTest()
2726
{
2827
_service = ConfigureService(ExpectedResponse);
2928
}
3029

31-
private PostalpincodeIn ConfigureService(string response)
30+
private static PostalpincodeIn ConfigureService(string response)
3231
{
33-
_handlerMock = new Mock<HttpMessageHandler>();
32+
var handlerMock = new Mock<HttpMessageHandler>();
3433

35-
_handlerMock
34+
handlerMock
3635
.Protected()
3736
.Setup<Task<HttpResponseMessage>>(
3837
SendAsync,
3938
ItExpr.IsAny<HttpRequestMessage>(),
4039
ItExpr.IsAny<CancellationToken>()
4140
)
42-
.ReturnsAsync(new HttpResponseMessage()
41+
.ReturnsAsync(new HttpResponseMessage
4342
{
4443
StatusCode = HttpStatusCode.OK,
4544
Content = new StringContent(response),
4645
})
4746
.Verifiable();
4847

49-
var httpClient = new HttpClient(_handlerMock.Object)
48+
var httpClient = new HttpClient(handlerMock.Object)
5049
{
5150
BaseAddress = new Uri(MockUri),
5251
};
@@ -55,7 +54,7 @@ private PostalpincodeIn ConfigureService(string response)
5554
}
5655

5756
[Fact]
58-
public void ConstructorTest()
57+
public static void ConstructorTest()
5958
{
6059
var actual = new PostalpincodeIn();
6160
Assert.NotNull(actual);
@@ -81,15 +80,15 @@ public void MustGetPostcodesObject()
8180
}
8281

8382
[Fact]
84-
public async void MustGetPostcodesAsync()
83+
public async Task MustGetPostcodesAsync()
8584
{
8685
var actual = await _service.ExecuteAsync(PostalPinCodeTest);
8786

8887
Assert.Equal(ExpectedResponse, actual);
8988
}
9089

9190
[Fact]
92-
public async void MustGetPostcodesObjectAsync()
91+
public async Task MustGetPostcodesObjectAsync()
9392
{
9493
var actual = await _service.GetPostcodeAsync<PostalpincodeInModel>(PostalPinCodeTest);
9594

CoreZipCode.Tests/Services/Postcode/PostcodesIoApi/PostcodesIoTest.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,33 +20,32 @@ public class PostcodesIoTest
2020
private const int ExpectedStatusSuccess = 200;
2121
private const int ExpectedResultQuality = 1;
2222

23-
private Mock<HttpMessageHandler> _handlerMock;
2423
private readonly PostcodesIo _service;
2524

2625
public PostcodesIoTest()
2726
{
2827
_service = ConfigureService(ExpectedResponse);
2928
}
3029

31-
private PostcodesIo ConfigureService(string response)
30+
private static PostcodesIo ConfigureService(string response)
3231
{
33-
_handlerMock = new Mock<HttpMessageHandler>();
32+
var handlerMock = new Mock<HttpMessageHandler>();
3433

35-
_handlerMock
34+
handlerMock
3635
.Protected()
3736
.Setup<Task<HttpResponseMessage>>(
3837
SendAsync,
3938
ItExpr.IsAny<HttpRequestMessage>(),
4039
ItExpr.IsAny<CancellationToken>()
4140
)
42-
.ReturnsAsync(new HttpResponseMessage()
41+
.ReturnsAsync(new HttpResponseMessage
4342
{
4443
StatusCode = HttpStatusCode.OK,
4544
Content = new StringContent(response),
4645
})
4746
.Verifiable();
4847

49-
var httpClient = new HttpClient(_handlerMock.Object)
48+
var httpClient = new HttpClient(handlerMock.Object)
5049
{
5150
BaseAddress = new Uri(MockUri),
5251
};
@@ -55,7 +54,7 @@ private PostcodesIo ConfigureService(string response)
5554
}
5655

5756
[Fact]
58-
public void ConstructorTest()
57+
public static void ConstructorTest()
5958
{
6059
var actual = new PostcodesIo();
6160
Assert.NotNull(actual);
@@ -81,15 +80,15 @@ public void MustGetPostcodesObject()
8180
}
8281

8382
[Fact]
84-
public async void MustGetPostcodesAsync()
83+
public async Task MustGetPostcodesAsync()
8584
{
8685
var actual = await _service.ExecuteAsync(PostalPinCodeTest);
8786

8887
Assert.Equal(ExpectedResponse, actual);
8988
}
9089

9190
[Fact]
92-
public async void MustGetPostcodesObjectAsync()
91+
public async Task MustGetPostcodesObjectAsync()
9392
{
9493
var actual = await _service.GetPostcodeAsync<PostcodesIoModel>(PostalPinCodeTest);
9594

CoreZipCode.Tests/Services/ZipCode/SmartyStreetsApi/SmartyStreetsTest.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,33 +33,32 @@ public class SmartyStreetsTest
3333

3434
private readonly SmartyStreets _service;
3535
private readonly SmartyStreets _serviceParam;
36-
private Mock<HttpMessageHandler> _handlerMock;
3736

3837
public SmartyStreetsTest()
3938
{
4039
_service = ConfigureService(ExpectedZipcodeResponse);
4140
_serviceParam = ConfigureService(ExpectedParamResponse);
4241
}
4342

44-
private SmartyStreets ConfigureService(string response)
43+
private static SmartyStreets ConfigureService(string response)
4544
{
46-
_handlerMock = new Mock<HttpMessageHandler>();
45+
var handlerMock = new Mock<HttpMessageHandler>();
4746

48-
_handlerMock
47+
handlerMock
4948
.Protected()
5049
.Setup<Task<HttpResponseMessage>>(
5150
SendAsync,
5251
ItExpr.IsAny<HttpRequestMessage>(),
5352
ItExpr.IsAny<CancellationToken>()
5453
)
55-
.ReturnsAsync(new HttpResponseMessage()
54+
.ReturnsAsync(new HttpResponseMessage
5655
{
5756
StatusCode = HttpStatusCode.OK,
5857
Content = new StringContent(response),
5958
})
6059
.Verifiable();
6160

62-
var httpClient = new HttpClient(_handlerMock.Object)
61+
var httpClient = new HttpClient(handlerMock.Object)
6362
{
6463
BaseAddress = new Uri(MockUri)
6564
};
@@ -68,14 +67,14 @@ private SmartyStreets ConfigureService(string response)
6867
}
6968

7069
[Fact]
71-
public void ConstructorTest()
70+
public static void ConstructorTest()
7271
{
7372
var actual = new SmartyStreets(AuthId, AuthToken);
7473
Assert.NotNull(actual);
7574
}
7675

7776
[Fact]
78-
public void ConstructorNullTest()
77+
public static void ConstructorNullTest()
7978
{
8079
Assert.Throws<ArgumentNullException>(() => new SmartyStreets(new HttpClient(), AuthId, null));
8180
Assert.Throws<ArgumentNullException>(() => new SmartyStreets(new HttpClient(), null, AuthToken));
@@ -152,23 +151,23 @@ public void MustThrowTheExceptions()
152151
}
153152

154153
[Fact]
155-
public async void MustGetSingleZipCodeJsonStringAsync()
154+
public async Task MustGetSingleZipCodeJsonStringAsync()
156155
{
157156
var actual = await _service.ExecuteAsync(ZipCodeTest);
158157

159158
Assert.Equal(ExpectedZipcodeResponse, actual);
160159
}
161160

162161
[Fact]
163-
public async void MustGetListZipCodeJsonStringAsync()
162+
public async Task MustGetListZipCodeJsonStringAsync()
164163
{
165164
var actual = await _serviceParam.ExecuteAsync(SmartyStreetsParameterState, SmartyStreetsParameterCity, SmartyStreetsParameterStreet);
166165

167166
Assert.Equal(ExpectedParamResponse, actual);
168167
}
169168

170169
[Fact]
171-
public async void MustGetSingleZipCodeObjectAsync()
170+
public async Task MustGetSingleZipCodeObjectAsync()
172171
{
173172
var actual = await _service.GetAddressAsync<List<SmartyStreetsModel>>(ZipCodeTest);
174173

@@ -178,7 +177,7 @@ public async void MustGetSingleZipCodeObjectAsync()
178177
}
179178

180179
[Fact]
181-
public async void MustGetZipCodeByParamsListAsync()
180+
public async Task MustGetZipCodeByParamsListAsync()
182181
{
183182
var actual = await _serviceParam.ListAddressesAsync<SmartyStreetsParamsModel>(SmartyStreetsParameterState, SmartyStreetsParameterCity, SmartyStreetsParameterStreet);
184183

0 commit comments

Comments
 (0)