@@ -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,28 @@ 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\" }]}" ;
330
+
331
+ Assert . NotNull ( requestContent ) ;
332
+ Assert . True ( batchRequestContent . BatchRequestSteps . Count . Equals ( 1 ) ) ;
333
+ Assert . Equal ( expectedContent , requestContent ) ;
334
+ }
335
+
314
336
[ Fact ]
315
337
public async System . Threading . Tasks . Task BatchRequestContent_GetBatchRequestContentSupportsNonJsonPayloadAsync ( )
316
338
{
@@ -331,7 +353,7 @@ public async System.Threading.Tasks.Task BatchRequestContent_GetBatchRequestCont
331
353
string requestContent ;
332
354
// we do this to get a version of the json that is indented
333
355
using ( Stream requestStream = await batchRequestContent . GetBatchRequestContentAsync ( ) )
334
- using ( JsonDocument jsonDocument = JsonDocument . Parse ( requestStream ) )
356
+ using ( JsonDocument jsonDocument = await JsonDocument . ParseAsync ( requestStream ) )
335
357
{
336
358
requestContent = JsonSerializer . Serialize ( jsonDocument . RootElement , new JsonSerializerOptions ( ) { WriteIndented = true } ) ;
337
359
}
@@ -409,7 +431,7 @@ public async System.Threading.Tasks.Task BatchRequestContent_GetBatchRequestCont
409
431
string requestContent ;
410
432
// we do this to get a version of the json that is indented
411
433
using ( Stream requestStream = await batchRequestContent . GetBatchRequestContentAsync ( ) )
412
- using ( JsonDocument jsonDocument = JsonDocument . Parse ( requestStream ) )
434
+ using ( JsonDocument jsonDocument = await JsonDocument . ParseAsync ( requestStream ) )
413
435
{
414
436
requestContent = JsonSerializer . Serialize ( jsonDocument . RootElement , new JsonSerializerOptions ( ) { WriteIndented = true } ) ;
415
437
}
@@ -532,7 +554,7 @@ public void BatchRequestContent_AddBatchRequestStepWithHttpRequestMessageToBatch
532
554
533
555
// Assert
534
556
var exception = Assert . Throws < ArgumentException > ( ( ) => batchRequestContent . AddBatchRequestStep ( extraHttpRequestMessage ) ) ; //Assert we throw exception on excess add
535
- // Assert.Equal(ErrorConstants.Codes .MaximumValueExceeded, exception.Error.Code );
557
+ Assert . Equal ( ErrorConstants . Messages . MaximumValueExceeded , exception . Message ) ;
536
558
Assert . NotNull ( batchRequestContent . BatchRequestSteps ) ;
537
559
Assert . True ( batchRequestContent . BatchRequestSteps . Count . Equals ( CoreConstants . BatchRequest . MaxNumberOfRequests ) ) ;
538
560
}
@@ -612,7 +634,7 @@ public async Task BatchRequestContent_AddBatchRequestStepWithBaseRequestToBatchR
612
634
var exception = await Assert . ThrowsAsync < ArgumentException > ( ( ) => batchRequestContent . AddBatchRequestStepAsync ( extraRequestInformation ) ) ;
613
635
614
636
// Assert
615
- // Assert.Equal(ErrorConstants.Codes .MaximumValueExceeded, exception.Error.Code );
637
+ Assert . Equal ( ErrorConstants . Messages . MaximumValueExceeded , exception . Message ) ;
616
638
Assert . NotNull ( batchRequestContent . BatchRequestSteps ) ;
617
639
Assert . True ( batchRequestContent . BatchRequestSteps . Count . Equals ( CoreConstants . BatchRequest . MaxNumberOfRequests ) ) ;
618
640
}
0 commit comments