From 11b8d3b4cfa603ee095aee645310253ed1b3447d Mon Sep 17 00:00:00 2001 From: ElizabethOkerio Date: Tue, 18 Oct 2022 07:53:05 +0300 Subject: [PATCH] update based on review comments --- .../BulkOperation/BulkOperationTest.cs | 36 +++++-------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/BulkOperation/BulkOperationTest.cs b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/BulkOperation/BulkOperationTest.cs index 6cc2976d50..b0bf21caba 100644 --- a/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/BulkOperation/BulkOperationTest.cs +++ b/test/E2ETest/Microsoft.Test.E2E.AspNet.OData/Build.AspNet/BulkOperation/BulkOperationTest.cs @@ -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"); @@ -151,6 +159,7 @@ 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); @@ -158,33 +167,6 @@ public async Task PostEmployee_WithFullMetadata() } } - [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 } }