Skip to content

Commit

Permalink
update based on review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ElizabethOkerio committed Oct 18, 2022
1 parent d1353ca commit 11b8d3b
Showing 1 changed file with 9 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ public async Task PostEmployee_WithFullMetadata()
'Name':'SqlUD'
}";

string expectedResponse = "{" +
"\"@odata.context\":\"" + this.BaseAddress + "/convention/$metadata#Employees/$entity\"," +
"\"@odata.type\":\"#Microsoft.Test.E2E.AspNet.OData.BulkOperation.Employee\"," +
"\"@odata.id\":\"" + this.BaseAddress + "/convention/Employees(0)\"," +
"\"@odata.editLink\":\"" + this.BaseAddress + "/convention/Employees(0)\",\"ID\":0,\"Name\":\"SqlUD\",\"SkillSet@odata.type\":\"#Collection(Microsoft.Test.E2E.AspNet.OData.BulkOperation.Skill)\",\"SkillSet\":[],\"Gender@odata.type\":\"#Microsoft.Test.E2E.AspNet.OData.BulkOperation.Gender\",\"Gender\":\"0\",\"AccessLevel@odata.type\":\"#Microsoft.Test.E2E.AspNet.OData.BulkOperation.AccessLevel\",\"AccessLevel\":\"0\",\"FavoriteSports\":null," +
"\"Friends@odata.associationLink\":\"" + this.BaseAddress + "/convention/Employees(0)/Friends/$ref\",\"Friends@odata.navigationLink\":\"" + this.BaseAddress + "/convention/Employees(0)/Friends\",\"NewFriends@odata.associationLink\":\"" + this.BaseAddress + "/convention/Employees(0)/NewFriends/$ref\",\"NewFriends@odata.navigationLink\":\"" + this.BaseAddress + "/convention/Employees(0)/NewFriends\",\"UnTypedFriends@odata.associationLink\":\"" + this.BaseAddress + "/convention/Employees(0)/UnTypedFriends/$ref\"," +
"\"UnTypedFriends@odata.navigationLink\":\"" + this.BaseAddress + "/convention/Employees(0)/UnTypedFriends\",\"#Microsoft.Test.E2E.AspNet.OData.BulkOperation.AddSkill\":{\"title\":\"AddSkill\",\"target\":\"" + this.BaseAddress + "/convention/Employees(0)/Microsoft.Test.E2E.AspNet.OData.BulkOperation.AddSkill\"},\"#Microsoft.Test.E2E.AspNet.OData.BulkOperation.GetAccessLevel\":{\"title\":\"GetAccessLevel\",\"target\":\"" + this.BaseAddress + "/convention/Employees(0)/Microsoft.Test.E2E.AspNet.OData.BulkOperation.GetAccessLevel()\"}}";

var requestForPatch = new HttpRequestMessage(new HttpMethod("POST"), requestUri);

StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
Expand All @@ -151,40 +159,14 @@ public async Task PostEmployee_WithFullMetadata()
{
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var json = response.Content.ReadAsStringAsync().Result;
Assert.Equal(expectedResponse.ToString().ToLower(), json.ToString().ToLower());
Assert.Contains("SqlUD", json);
Assert.Contains(friendsNavigationLink, json);
Assert.Contains(newFriendsNavigationLink, json);
Assert.Contains(untypedFriendsNavigationLink, json);
}
}

[Fact]
public async Task GetEmployee_WithFullMetadata()
{
//Arrange

string requestUri = this.BaseAddress + "/convention/Employees(1)?$format=application/json;odata.metadata=full";

var requestForPatch = new HttpRequestMessage(new HttpMethod("GET"), requestUri);

string friendsNavigationLink = "Friends@odata.navigationLink";
string newFriendsNavigationLink = "NewFriends@odata.navigationLink";
string untypedFriendsNavigationLink = "UnTypedFriends@odata.navigationLink";

string notexpected = "Friends\":[{\"@odata.type\":\"#Microsoft.Test.E2E.AspNet.OData.BulkOperation.Friend\"";

//Act & Assert
using (HttpResponseMessage response = await this.Client.SendAsync(requestForPatch))
{
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var json = response.Content.ReadAsStringAsync().Result;
Assert.DoesNotContain(notexpected, json);
Assert.Contains(friendsNavigationLink, json);
Assert.Contains(newFriendsNavigationLink, json);
Assert.Contains(untypedFriendsNavigationLink, json);
}
}

#endregion
}
}

0 comments on commit 11b8d3b

Please sign in to comment.