@@ -662,25 +662,30 @@ public async Task OpenReadAsyncOverload_AllowModifications()
662662 // Arrange
663663 byte [ ] data0 = GetRandomBuffer ( size ) ;
664664 byte [ ] data1 = GetRandomBuffer ( size ) ;
665- byte [ ] expectedData = new byte [ 2 * size ] ;
666- Array . Copy ( data0 , 0 , expectedData , 0 , size ) ;
667- Array . Copy ( data1 , 0 , expectedData , size , size ) ;
665+ byte [ ] expectedDataBeforeModify = new byte [ size ] ;
666+ byte [ ] expectedDataAfterModify = new byte [ size ] ;
667+ Array . Copy ( data0 , 0 , expectedDataBeforeModify , 0 , size ) ;
668+ Array . Copy ( data1 , 0 , expectedDataAfterModify , 0 , size ) ;
668669
669670 TResourceClient client = GetResourceClient ( disposingContainer . Container ) ;
670671 await StageDataAsync ( client , new MemoryStream ( data0 ) ) ;
671672
672673 // Act
673674 Stream outputStream = await OpenReadAsyncOverload ( client , allowModifications : true ) ;
674- byte [ ] outputBytes = new byte [ 2 * size ] ;
675- await outputStream . ReadAsync ( outputBytes , 0 , size ) ;
675+ byte [ ] outputBytesBeforeModify = new byte [ size ] ;
676+ await outputStream . ReadAsync ( outputBytesBeforeModify , 0 , size ) ;
676677
677678 // Modify the blob.
678679 await ModifyDataAsync ( client , new MemoryStream ( data1 ) , ModifyDataMode . Append ) ;
679680
680- await outputStream . ReadAsync ( outputBytes , size , size ) ;
681+ byte [ ] outputBytesAfterModify = new byte [ size ] ;
682+ byte [ ] emptyBytes = new byte [ size ] ;
683+ await outputStream . ReadAsync ( outputBytesAfterModify , 0 , size ) ;
681684
682685 // Assert
683- TestHelper . AssertSequenceEqual ( expectedData , outputBytes ) ;
686+ TestHelper . AssertSequenceEqual ( expectedDataBeforeModify , outputBytesBeforeModify ) ;
687+ TestHelper . AssertSequenceEqual ( expectedDataAfterModify , outputBytesAfterModify ) ;
688+ Assert . AreNotEqual ( emptyBytes , outputBytesAfterModify ) ;
684689 }
685690
686691 [ RecordedTest ]
@@ -692,25 +697,30 @@ public async Task OpenReadAsyncOverload_NotAllowModifications()
692697 // Arrange
693698 byte [ ] data0 = GetRandomBuffer ( size ) ;
694699 byte [ ] data1 = GetRandomBuffer ( size ) ;
695- byte [ ] expectedData = new byte [ 2 * size ] ;
696- Array . Copy ( data0 , 0 , expectedData , 0 , size ) ;
697- Array . Copy ( data1 , 0 , expectedData , size , size ) ;
700+ byte [ ] expectedDataBeforeModify = new byte [ size ] ;
701+ byte [ ] expectedDataAfterModify = new byte [ size ] ;
702+ Array . Copy ( data0 , 0 , expectedDataBeforeModify , 0 , size ) ;
703+ Array . Copy ( data1 , 0 , expectedDataAfterModify , 0 , size ) ;
698704
699705 TResourceClient client = GetResourceClient ( disposingContainer . Container ) ;
700706 await StageDataAsync ( client , new MemoryStream ( data0 ) ) ;
701707
702708 // Act
703709 Stream outputStream = await OpenReadAsyncOverload ( client , allowModifications : false ) ;
704- byte [ ] outputBytes = new byte [ 2 * size ] ;
705- await outputStream . ReadAsync ( outputBytes , 0 , size ) ;
710+ byte [ ] outputBytesBeforeModify = new byte [ size ] ;
711+ await outputStream . ReadAsync ( outputBytesBeforeModify , 0 , size ) ;
706712
707713 // Modify the blob.
708714 await ModifyDataAsync ( client , new MemoryStream ( data1 ) , ModifyDataMode . Append ) ;
709715
710- await outputStream . ReadAsync ( outputBytes , size , size ) ;
716+ byte [ ] outputBytesAfterModify = new byte [ size ] ;
717+ byte [ ] emptyBytes = new byte [ size ] ;
718+ await outputStream . ReadAsync ( outputBytesAfterModify , 0 , size ) ;
711719
712720 // Assert
713- Assert . AreNotEqual ( expectedData , outputBytes ) ;
721+ TestHelper . AssertSequenceEqual ( expectedDataBeforeModify , outputBytesBeforeModify ) ;
722+ Assert . AreNotEqual ( expectedDataAfterModify , outputBytesAfterModify ) ;
723+ TestHelper . AssertSequenceEqual ( emptyBytes , outputBytesAfterModify ) ;
714724 }
715725 }
716726}
0 commit comments