@@ -181,7 +181,7 @@ public void BatchRequestContent_RemoveBatchRequestStepWithIdForNonExistingId()
181181
182182 Assert . False ( isSuccess ) ;
183183 Assert . True ( batchRequestContent . BatchRequestSteps . Count . Equals ( 2 ) ) ;
184- Assert . Same ( batchRequestStep2 . DependsOn . First ( ) , batchRequestContent . BatchRequestSteps [ "2" ] . DependsOn . First ( ) ) ;
184+ Assert . Same ( batchRequestStep2 . DependsOn [ 0 ] , batchRequestContent . BatchRequestSteps [ "2" ] . DependsOn [ 0 ] ) ;
185185 }
186186
187187 [ Fact ]
@@ -311,6 +311,29 @@ public async System.Threading.Tasks.Task BatchRequestContent_GetBatchRequestCont
311311 Assert . Equal ( expectedContent , requestContent ) ;
312312 }
313313
314+ [ Fact ]
315+ public async System . Threading . Tasks . Task BatchRequestContent_GetBatchRequestContentFromRequestInformationDoesNotAddAuthHeaderAsync ( )
316+ {
317+ BatchRequestContent batchRequestContent = new BatchRequestContent ( client ) ;
318+ RequestInformation requestInformation = new RequestInformation ( ) { HttpMethod = Method . GET , UrlTemplate = REQUEST_URL } ;
319+ await batchRequestContent . AddBatchRequestStepAsync ( requestInformation , "2" ) ;
320+
321+ string requestContent ;
322+ // We get the contents of the stream as string for comparison.
323+ using ( Stream requestStream = await batchRequestContent . GetBatchRequestContentAsync ( ) )
324+ using ( StreamReader reader = new StreamReader ( requestStream ) )
325+ {
326+ requestContent = await reader . ReadToEndAsync ( ) ;
327+ }
328+
329+ string expectedContent = "{\" requests\" :[{\" id\" :\" 2\" ,\" url\" :\" /me\" ,\" method\" :\" GET\" }]}" ; //Auth Header Absent.
330+
331+ Assert . NotNull ( requestContent ) ;
332+ Assert . IsType < BaseGraphRequestAdapter > ( batchRequestContent . RequestAdapter ) ;
333+ Assert . True ( batchRequestContent . BatchRequestSteps . Count . Equals ( 1 ) ) ;
334+ Assert . Equal ( expectedContent , requestContent ) ;
335+ }
336+
314337 [ Fact ]
315338 public async System . Threading . Tasks . Task BatchRequestContent_GetBatchRequestContentSupportsNonJsonPayloadAsync ( )
316339 {
@@ -331,7 +354,7 @@ public async System.Threading.Tasks.Task BatchRequestContent_GetBatchRequestCont
331354 string requestContent ;
332355 // we do this to get a version of the json that is indented
333356 using ( Stream requestStream = await batchRequestContent . GetBatchRequestContentAsync ( ) )
334- using ( JsonDocument jsonDocument = JsonDocument . Parse ( requestStream ) )
357+ using ( JsonDocument jsonDocument = await JsonDocument . ParseAsync ( requestStream ) )
335358 {
336359 requestContent = JsonSerializer . Serialize ( jsonDocument . RootElement , new JsonSerializerOptions ( ) { WriteIndented = true } ) ;
337360 }
@@ -409,7 +432,7 @@ public async System.Threading.Tasks.Task BatchRequestContent_GetBatchRequestCont
409432 string requestContent ;
410433 // we do this to get a version of the json that is indented
411434 using ( Stream requestStream = await batchRequestContent . GetBatchRequestContentAsync ( ) )
412- using ( JsonDocument jsonDocument = JsonDocument . Parse ( requestStream ) )
435+ using ( JsonDocument jsonDocument = await JsonDocument . ParseAsync ( requestStream ) )
413436 {
414437 requestContent = JsonSerializer . Serialize ( jsonDocument . RootElement , new JsonSerializerOptions ( ) { WriteIndented = true } ) ;
415438 }
@@ -532,7 +555,7 @@ public void BatchRequestContent_AddBatchRequestStepWithHttpRequestMessageToBatch
532555
533556 // Assert
534557 var exception = Assert . Throws < ArgumentException > ( ( ) => batchRequestContent . AddBatchRequestStep ( extraHttpRequestMessage ) ) ; //Assert we throw exception on excess add
535- // Assert.Equal(ErrorConstants.Codes .MaximumValueExceeded, exception.Error.Code );
558+ Assert . Equal ( string . Format ( ErrorConstants . Messages . MaximumValueExceeded , "Number of batch request steps" , CoreConstants . BatchRequest . MaxNumberOfRequests ) , exception . Message ) ;
536559 Assert . NotNull ( batchRequestContent . BatchRequestSteps ) ;
537560 Assert . True ( batchRequestContent . BatchRequestSteps . Count . Equals ( CoreConstants . BatchRequest . MaxNumberOfRequests ) ) ;
538561 }
@@ -612,7 +635,7 @@ public async Task BatchRequestContent_AddBatchRequestStepWithBaseRequestToBatchR
612635 var exception = await Assert . ThrowsAsync < ArgumentException > ( ( ) => batchRequestContent . AddBatchRequestStepAsync ( extraRequestInformation ) ) ;
613636
614637 // Assert
615- // Assert.Equal(ErrorConstants.Codes .MaximumValueExceeded, exception.Error.Code );
638+ Assert . Equal ( string . Format ( ErrorConstants . Messages . MaximumValueExceeded , "Number of batch request steps" , CoreConstants . BatchRequest . MaxNumberOfRequests ) , exception . Message ) ;
616639 Assert . NotNull ( batchRequestContent . BatchRequestSteps ) ;
617640 Assert . True ( batchRequestContent . BatchRequestSteps . Count . Equals ( CoreConstants . BatchRequest . MaxNumberOfRequests ) ) ;
618641 }
0 commit comments