@@ -181,7 +181,7 @@ public void BatchRequestContent_RemoveBatchRequestStepWithIdForNonExistingId()
181
181
182
182
Assert . False ( isSuccess ) ;
183
183
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 ] ) ;
185
185
}
186
186
187
187
[ Fact ]
@@ -311,6 +311,29 @@ public async System.Threading.Tasks.Task BatchRequestContent_GetBatchRequestCont
311
311
Assert . Equal ( expectedContent , requestContent ) ;
312
312
}
313
313
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
+
314
337
[ Fact ]
315
338
public async System . Threading . Tasks . Task BatchRequestContent_GetBatchRequestContentSupportsNonJsonPayloadAsync ( )
316
339
{
@@ -331,7 +354,7 @@ public async System.Threading.Tasks.Task BatchRequestContent_GetBatchRequestCont
331
354
string requestContent ;
332
355
// we do this to get a version of the json that is indented
333
356
using ( Stream requestStream = await batchRequestContent . GetBatchRequestContentAsync ( ) )
334
- using ( JsonDocument jsonDocument = JsonDocument . Parse ( requestStream ) )
357
+ using ( JsonDocument jsonDocument = await JsonDocument . ParseAsync ( requestStream ) )
335
358
{
336
359
requestContent = JsonSerializer . Serialize ( jsonDocument . RootElement , new JsonSerializerOptions ( ) { WriteIndented = true } ) ;
337
360
}
@@ -409,7 +432,7 @@ public async System.Threading.Tasks.Task BatchRequestContent_GetBatchRequestCont
409
432
string requestContent ;
410
433
// we do this to get a version of the json that is indented
411
434
using ( Stream requestStream = await batchRequestContent . GetBatchRequestContentAsync ( ) )
412
- using ( JsonDocument jsonDocument = JsonDocument . Parse ( requestStream ) )
435
+ using ( JsonDocument jsonDocument = await JsonDocument . ParseAsync ( requestStream ) )
413
436
{
414
437
requestContent = JsonSerializer . Serialize ( jsonDocument . RootElement , new JsonSerializerOptions ( ) { WriteIndented = true } ) ;
415
438
}
@@ -532,7 +555,7 @@ public void BatchRequestContent_AddBatchRequestStepWithHttpRequestMessageToBatch
532
555
533
556
// Assert
534
557
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 ) ;
536
559
Assert . NotNull ( batchRequestContent . BatchRequestSteps ) ;
537
560
Assert . True ( batchRequestContent . BatchRequestSteps . Count . Equals ( CoreConstants . BatchRequest . MaxNumberOfRequests ) ) ;
538
561
}
@@ -612,7 +635,7 @@ public async Task BatchRequestContent_AddBatchRequestStepWithBaseRequestToBatchR
612
635
var exception = await Assert . ThrowsAsync < ArgumentException > ( ( ) => batchRequestContent . AddBatchRequestStepAsync ( extraRequestInformation ) ) ;
613
636
614
637
// 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 ) ;
616
639
Assert . NotNull ( batchRequestContent . BatchRequestSteps ) ;
617
640
Assert . True ( batchRequestContent . BatchRequestSteps . Count . Equals ( CoreConstants . BatchRequest . MaxNumberOfRequests ) ) ;
618
641
}
0 commit comments