Skip to content

Commit

Permalink
Change ETagsOtherTypesTest for independent parallel running
Browse files Browse the repository at this point in the history
  • Loading branch information
xuzhg committed Feb 14, 2020
1 parent aa5a57f commit 0ec34b4
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,21 @@ public async Task GetEntryWithIfNoneMatchShouldReturnNotModifiedETagsTest_ForDou
var result = json.GetValue("value") as JArray;
Assert.NotNull(result);

// check the first
eTag = result[2]["@odata.etag"].ToString();
// check the first unchanged,
// because #0, #1, #2 will change potentially running in parallel by other tests.
eTag = result[3]["@odata.etag"].ToString();
Assert.False(String.IsNullOrEmpty(eTag));
Assert.Equal("W/\"Ni4w\"", eTag);
Assert.Equal("W/\"OC4w\"", eTag);

EntityTagHeaderValue parsedValue;
Assert.True(EntityTagHeaderValue.TryParse(eTag, out parsedValue));
IDictionary<string, object> tags = this.ParseETag(parsedValue);
KeyValuePair<string, object> pair = Assert.Single(tags);
Single value = Assert.IsType<Single>(pair.Value);
Assert.Equal((Single)6.0, value);
Assert.Equal((Single)8.0, value);
}

var getRequestWithEtag = new HttpRequestMessage(HttpMethod.Get, this.BaseAddress + "/double/ETagsCustomers(2)");
var getRequestWithEtag = new HttpRequestMessage(HttpMethod.Get, this.BaseAddress + "/double/ETagsCustomers(3)");
getRequestWithEtag.Headers.IfNoneMatch.ParseAdd(eTag);
using (var response = await Client.SendAsync(getRequestWithEtag))
{
Expand All @@ -103,20 +104,21 @@ public async Task GetEntryWithIfNoneMatchShouldReturnNotModifiedETagsTest_ForSho
var result = json.GetValue("value") as JArray;
Assert.NotNull(result);

// check the second
eTag = result[1]["@odata.etag"].ToString();
// check the first unchanged,
// because #0, #1, #2 will change potentially running in parallel by other tests.
eTag = result[3]["@odata.etag"].ToString();
Assert.False(String.IsNullOrEmpty(eTag));
Assert.Equal("W/\"MzI3NjY=\"", eTag);
Assert.Equal("W/\"MzI3NjQ=\"", eTag);

EntityTagHeaderValue parsedValue;
Assert.True(EntityTagHeaderValue.TryParse(eTag, out parsedValue));
IDictionary<string, object> tags = this.ParseETag(parsedValue);
KeyValuePair<string, object> pair = Assert.Single(tags);
int value = Assert.IsType<int>(pair.Value);
Assert.Equal((short)32766, value);
Assert.Equal((short)32764, value);
}

var getRequestWithEtag = new HttpRequestMessage(HttpMethod.Get, this.BaseAddress + "/short/ETagsCustomers(1)");
var getRequestWithEtag = new HttpRequestMessage(HttpMethod.Get, this.BaseAddress + "/short/ETagsCustomers(3)");
getRequestWithEtag.Headers.IfNoneMatch.ParseAdd(eTag);
using (var response = await Client.SendAsync(getRequestWithEtag))
{
Expand Down

0 comments on commit 0ec34b4

Please sign in to comment.