diff --git a/Microsoft.Azure.Cosmos/src/Resource/Throughput/ThroughputResponse.cs b/Microsoft.Azure.Cosmos/src/Resource/Throughput/ThroughputResponse.cs index c6c96bda77..5cca91dd9c 100644 --- a/Microsoft.Azure.Cosmos/src/Resource/Throughput/ThroughputResponse.cs +++ b/Microsoft.Azure.Cosmos/src/Resource/Throughput/ThroughputResponse.cs @@ -82,7 +82,7 @@ public bool? IsReplacePending { if (this.Headers.GetHeaderValue(WFConstants.BackendHeaders.OfferReplacePending) != null) { - return Boolean.Parse(this.Headers.GetHeaderValue(WFConstants.BackendHeaders.MinimumRUsForOffer)); + return Boolean.Parse(this.Headers.GetHeaderValue(WFConstants.BackendHeaders.OfferReplacePending)); } return null; } @@ -97,4 +97,4 @@ public static implicit operator ThroughputProperties(ThroughputResponse response return response.Resource; } } -} \ No newline at end of file +} diff --git a/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Resource/Throughput/ThroughputResponseTests.cs b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Resource/Throughput/ThroughputResponseTests.cs new file mode 100644 index 0000000000..e7df232d01 --- /dev/null +++ b/Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Resource/Throughput/ThroughputResponseTests.cs @@ -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); + } + } +} diff --git a/changelog.md b/changelog.md index a1615dc66a..c321458897 100644 --- a/changelog.md +++ b/changelog.md @@ -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 ## [3.4.1](https://www.nuget.org/packages/Microsoft.Azure.Cosmos/3.4.1) - 2019-11-06