Skip to content

Commit

Permalink
Fix ThroughputResponse.IsReplacePending (#1023)
Browse files Browse the repository at this point in the history
* Update ThroughputResponse.cs

fix the value that is being retrieved when mapping ThoughputResponse.IsReplacePending

* Update changelog.md

* add tests
  • Loading branch information
wahyuen authored and kirankumarkolli committed Nov 20, 2019
1 parent 505b8d9 commit 07dcca0
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public bool? IsReplacePending
{
if (this.Headers.GetHeaderValue<string>(WFConstants.BackendHeaders.OfferReplacePending) != null)
{
return Boolean.Parse(this.Headers.GetHeaderValue<string>(WFConstants.BackendHeaders.MinimumRUsForOffer));
return Boolean.Parse(this.Headers.GetHeaderValue<string>(WFConstants.BackendHeaders.OfferReplacePending));
}
return null;
}
Expand All @@ -97,4 +97,4 @@ public static implicit operator ThroughputProperties(ThroughputResponse response
return response.Resource;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System.Net;
using Microsoft.Azure.Documents;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Microsoft.Azure.Cosmos.Resource.Throughput
{
[TestClass]
public class ThroughputResponseTests
{
[TestMethod]
public void OfferReplacePendingHeaderNotSetReturnsNull()
{
ThroughputResponse throughputResponse =
new ThroughputResponse(HttpStatusCode.OK, new Headers(), null, null);

Assert.IsNull(throughputResponse.IsReplacePending);
}

[TestMethod]
public void OfferReplacePendingHeaderSetTrueReturnsTrue()
{
ThroughputResponse throughputResponse = new ThroughputResponse(HttpStatusCode.OK, new Headers
{
{WFConstants.BackendHeaders.OfferReplacePending, "true"}
}, null, null);

Assert.IsNotNull(throughputResponse.IsReplacePending);
Assert.IsTrue(throughputResponse.IsReplacePending.Value);
}

[TestMethod]
public void OfferReplacePendingHeaderSetFalseReturnsFalse()
{
ThroughputResponse throughputResponse = new ThroughputResponse(HttpStatusCode.OK, new Headers
{
{WFConstants.BackendHeaders.OfferReplacePending, "false"}
}, null, null);

Assert.IsNotNull(throughputResponse.IsReplacePending);
Assert.IsFalse(throughputResponse.IsReplacePending.Value);
}
}
}
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#988](https://github.com/Azure/azure-cosmos-dotnet-v3/pull/988) Fixed query mutating due to retry of gone / name cache is stale.
- [#999](https://github.com/Azure/azure-cosmos-dotnet-v3/pull/999) Fixed grabbing extra page and updated continuation token on exception path.
- [#1013](https://github.com/Azure/azure-cosmos-dotnet-v3/pull/1013) Gateway OperationCanceledException are now returned as request timeouts
- [#1023](https://github.com/Azure/azure-cosmos-dotnet-v3/pull/1023) Fixed ThroughputResponse.IsReplacePending header mapping

## <a name="3.4.1"/> [3.4.1](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.4.1) - 2019-11-06

Expand Down

0 comments on commit 07dcca0

Please sign in to comment.