Skip to content

Commit d51d3ea

Browse files
authored
Float estimates (#19)
* Add overload that takes a double as the estimate value for an issue.Issue Refactor the code that sets the estimate to allow both int and double to be passed in. Added test for the double estimate Update package versions to later versions. * Add ConfigureAwait(false) in 2 places that were previously missed.
1 parent 57b4387 commit d51d3ea

File tree

6 files changed

+61
-7
lines changed

6 files changed

+61
-7
lines changed

src/Pipeline/ThrowOnErrorResponsePolicy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public override void Process(HttpMessage message, ReadOnlyMemory<HttpPipelinePol
1616

1717
public override async ValueTask ProcessAsync(HttpMessage message, ReadOnlyMemory<HttpPipelinePolicy> pipeline)
1818
{
19-
await ProcessNextAsync(message, pipeline);
19+
await ProcessNextAsync(message, pipeline).ConfigureAwait(false);
2020
if (message.ResponseClassifier.IsErrorResponse(message))
2121
{
2222
throw new RequestFailedException(message.Response.Status, message.ToString());

src/Pipeline/ZenHubAuthenticationPolicy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public override async ValueTask ProcessAsync(HttpMessage message, ReadOnlyMemory
2323
#pragma warning disable CA1062 // Validate arguments of public methods
2424
message.Request.Headers.Add("X-Authentication-Token", _authToken);
2525
#pragma warning restore CA1062 // Validate arguments of public methods
26-
await ProcessNextAsync(message, pipeline);
26+
await ProcessNextAsync(message, pipeline).ConfigureAwait(false);
2727
}
2828
}
2929
}

src/ZenHub.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFrameworks>netstandard2.0</TargetFrameworks>
55
<LangVersion>preview</LangVersion>
6-
<VersionPrefix>1.1.0</VersionPrefix>
6+
<VersionPrefix>1.2.0</VersionPrefix>
77
</PropertyGroup>
88

99
<PropertyGroup>
@@ -21,13 +21,13 @@
2121
</PropertyGroup>
2222

2323
<ItemGroup>
24-
<PackageReference Include="Azure.Core" Version="1.0.0" />
25-
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.6">
24+
<PackageReference Include="Azure.Core" Version="1.2.1" />
25+
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
2626
<PrivateAssets>all</PrivateAssets>
2727
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2828
</PackageReference>
29-
<PackageReference Include="Octokit" Version="0.36.0" />
30-
<PackageReference Include="System.Text.Json" Version="4.6.0" />
29+
<PackageReference Include="Octokit" Version="0.47.0" />
30+
<PackageReference Include="System.Text.Json" Version="4.7.2" />
3131
</ItemGroup>
3232

3333
</Project>

src/ZenHubIssueClient.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ public async Task<Response<IssueDetails>> GetDetailsAsync(CancellationToken canc
4848
/// </summary>
4949
/// <param name="estimate">The value of the estimate</param>
5050
public async Task<Response> SetEstimateAsync(int estimate, CancellationToken cancellationToken = default)
51+
{
52+
return await SetEstimateInternalAsync(estimate, cancellationToken)
53+
.ConfigureAwait(false);
54+
}
55+
56+
/// <summary>
57+
/// Set the estimate on the issue
58+
/// </summary>
59+
/// <param name="estimate">The value of the estimate</param>
60+
public async Task<Response> SetEstimateAsync(double estimate, CancellationToken cancellationToken = default)
61+
{
62+
return await SetEstimateInternalAsync(estimate, cancellationToken)
63+
.ConfigureAwait(false);
64+
}
65+
66+
private async Task<Response> SetEstimateInternalAsync<T>(T estimate, CancellationToken cancellationToken = default)
5167
{
5268
var contentBody = new
5369
{

tests/ZenHubClient.Mock.Tests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,16 @@ public void SetIssueEstimate1()
193193
Assert.AreEqual(200, response.Status);
194194
}
195195

196+
[Test]
197+
public void SetIssueEstimate2()
198+
{
199+
long repoId = MockServer.repositoryId;
200+
int issueNumber = MockServer.issueNumber;
201+
202+
var response = _zenhubClient.GetIssueClient(repoId, issueNumber).SetEstimateAsync(1.5).GetAwaiter().GetResult();
203+
Assert.AreEqual(200, response.Status);
204+
}
205+
196206
[Test]
197207
public void AddIssueToReleaseReport1()
198208
{
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"Request": {
3+
"Path": {
4+
"Matchers": [
5+
{
6+
"Name": "ExactMatcher",
7+
"Pattern": "/p1/repositories/1/issues/2/estimate"
8+
}
9+
]
10+
},
11+
"Methods": [
12+
"put"
13+
],
14+
"Body": {
15+
"Matcher": {
16+
"Name": "ExactMatcher",
17+
"Pattern": "{\"estimate\":1.5}"
18+
}
19+
}
20+
},
21+
"Response": {
22+
"StatusCode": 200,
23+
"BodyAsJson": { "estimate": 1.5 },
24+
"Headers": {
25+
"Content-Type": "application/json"
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)