Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ThroughputResponse.IsReplacePending #1023

Merged
merged 5 commits into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
wahyuen marked this conversation as resolved.
Show resolved Hide resolved
}
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