22// Licensed under the MIT License. See License.txt in the project root for license information.
33
44using System . Net ;
5- using System . Net . Http ;
65using System . Threading . Tasks ;
76using Microsoft . AspNet . OData . Extensions ;
87using Microsoft . Test . E2E . AspNet . OData . Common . Execution ;
@@ -33,26 +32,25 @@ protected static void UpdateConfigure(WebRouteConfiguration configuration)
3332 [ Fact ]
3433 public async Task DeleteNavigationLink ( )
3534 {
36- var requestBaseUri = this . BaseAddress + "/Singers(0)/Albums" ;
35+ // For parallel running and no side effect, pay attention that key value is 1.
36+ // And for this test cases only, we don't need to reset the data source because it's only run once.
37+ var requestBaseUri = this . BaseAddress + "/Singers(1)/Albums" ;
3738
38- await ResetDataSource ( "Singers" ) ;
39- await ResetDataSource ( "Albums" ) ;
40-
41- //DELETE Singers(0)/Albums/$ref?$id=BaseAddress/Albums(0)
39+ //DELETE Singers(1)/Albums/$ref?$id=BaseAddress/Albums(1)
4240 var response = await this . Client . DeleteAsync ( string . Format ( requestBaseUri + "/$ref?$id={0}/Albums(0)" , this . BaseAddress ) ) ;
4341 Assert . Equal ( HttpStatusCode . NoContent , response . StatusCode ) ;
4442
45- //GET Singers(0 )/Albums
43+ //GET Singers(1 )/Albums
4644 response = await this . Client . GetAsync ( requestBaseUri ) ;
4745 var json = await response . Content . ReadAsObject < JObject > ( ) ;
4846 var result = json [ "value" ] as JArray ;
4947 Assert . Equal < int > ( 2 , result . Count ) ;
5048
51- //DELETE Singers(0 )/Albums/$ref?$id=../../Albums(0 )
49+ //DELETE Singers(1 )/Albums/$ref?$id=../../Albums(1 )
5250 response = await this . Client . DeleteAsync ( string . Format ( requestBaseUri + "/$ref?$id=../../Albums(1)" ) ) ;
5351 Assert . Equal ( HttpStatusCode . NoContent , response . StatusCode ) ;
5452
55- //GET Singers(0 )/Albums
53+ //GET Singers(1 )/Albums
5654 response = await this . Client . GetAsync ( requestBaseUri ) ;
5755 json = await response . Content . ReadAsObject < JObject > ( ) ;
5856 result = json [ "value" ] as JArray ;
@@ -62,23 +60,23 @@ public async Task DeleteNavigationLink()
6260 [ Fact ]
6361 public async Task DeleteContainedNavigationLink ( )
6462 {
65- var requestBaseUri = this . BaseAddress + "/Albums(5)/Sales" ;
66-
67- await ResetDataSource ( "Singers" ) ;
68- await ResetDataSource ( "Albums" ) ;
63+ // For parallel running and no side effect, pay attention that key value is 1.
64+ // And for this test cases only, we don't need to reset the data source because it's only run once.
65+ var requestBaseUri = this . BaseAddress + "/Albums(1)/Sales" ;
6966
70- var response = await this . Client . DeleteAsync ( string . Format ( requestBaseUri + "/$ref?$id={0}/Albums(5 )/Sales(6 )" , this . BaseAddress ) ) ;
67+ var response = await this . Client . DeleteAsync ( string . Format ( requestBaseUri + "/$ref?$id={0}/Albums(1 )/Sales(2 )" , this . BaseAddress ) ) ;
7168 Assert . Equal ( HttpStatusCode . NoContent , response . StatusCode ) ;
7269
73- //GET Singers(0)/Albums
70+ //GET Albums(1)/Sales
7471 response = await this . Client . GetAsync ( requestBaseUri ) ;
7572 var json = await response . Content . ReadAsObject < JObject > ( ) ;
7673 var result = json [ "value" ] as JArray ;
7774 Assert . Single ( result ) ;
7875
79- response = await this . Client . DeleteAsync ( string . Format ( requestBaseUri + "/$ref?$id=../../Albums(5 )/Sales(7 )" , this . BaseAddress ) ) ;
76+ response = await this . Client . DeleteAsync ( string . Format ( requestBaseUri + "/$ref?$id=../../Albums(1 )/Sales(3 )" , this . BaseAddress ) ) ;
8077 Assert . Equal ( HttpStatusCode . NoContent , response . StatusCode ) ;
8178
79+ // GET Albums(1)/Sales
8280 response = await this . Client . GetAsync ( requestBaseUri ) ;
8381 json = await response . Content . ReadAsObject < JObject > ( ) ;
8482 result = json [ "value" ] as JArray ;
@@ -88,23 +86,15 @@ public async Task DeleteContainedNavigationLink()
8886 [ Fact ]
8987 public async Task GetSingersNameOfAlbum ( )
9088 {
91- var requestBaseUri = this . BaseAddress + "/Albums(5)/Microsoft.Test.E2E.AspNet.OData.DollarId.GetSingers()?$filter=MasterPiece eq 'def'&$select=Name" ;
89+ // 3 is a magic test value and is verified at controller.
90+ var requestBaseUri = this . BaseAddress + "/Albums(3)/Microsoft.Test.E2E.AspNet.OData.DollarId.GetSingers()?$filter=MasterPiece eq 'def'&$select=Name" ;
9291
9392 var response = await this . Client . GetAsync ( requestBaseUri ) ;
9493 Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
9594
96- response = await this . Client . GetAsync ( requestBaseUri ) ;
9795 var json = await response . Content . ReadAsObject < JObject > ( ) ;
9896 var result = json [ "value" ] ;
9997 Assert . Equal ( "Name102" , ( string ) result [ 0 ] [ "Name" ] ) ;
10098 }
101-
102- private async Task < HttpResponseMessage > ResetDataSource ( string controller )
103- {
104- var uriReset = string . Format ( this . BaseAddress + "/{0}/Microsoft.Test.E2E.AspNet.OData.DollarId.ResetDataSource" , controller ) ;
105- var response = await this . Client . PostAsync ( uriReset , null ) ;
106-
107- return response ;
108- }
10999 }
110100}
0 commit comments