From d359460f78a64ba88b7f0a6bed6ae5771db764b2 Mon Sep 17 00:00:00 2001 From: Wah Yuen <4549796+wahyuen@users.noreply.github.com> Date: Tue, 19 Nov 2019 11:30:46 +0800 Subject: [PATCH 1/3] Update ThroughputResponse.cs fix the value that is being retrieved when mapping ThoughputResponse.IsReplacePending --- .../src/Resource/Throughput/ThroughputResponse.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 +} From 133478433d471cf097a542ed3c40ce2f11832942 Mon Sep 17 00:00:00 2001 From: Wah Yuen <4549796+wahyuen@users.noreply.github.com> Date: Tue, 19 Nov 2019 21:10:30 +0800 Subject: [PATCH 2/3] Update changelog.md --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 9267e72c76..affea11fb6 100644 --- a/changelog.md +++ b/changelog.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#944](https://github.com/Azure/azure-cosmos-dotnet-v3/pull/944) Change Feed Processor won't use user serializer for internal operations - [#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. +- [#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 From c26072a0669d9a5f401d72b20a16efbd290335c6 Mon Sep 17 00:00:00 2001 From: Wah Yuen Date: Tue, 19 Nov 2019 21:29:21 +0800 Subject: [PATCH 3/3] add tests --- .../Throughput/ThroughputResponseTests.cs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Resource/Throughput/ThroughputResponseTests.cs 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); + } + } +}