//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sendLargerFileWhichGrows() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SendLargerFileWhichGrows() { // given File file = TestDirectory.file("file"); StoreChannel writer = _fs.create(file); FileSender fileSender = new FileSender(new StoreResource(file, null, 16, _fs)); // when sbyte[] chunkA = WriteRandomBytes(writer, MAX_SIZE); sbyte[] chunkB = WriteRandomBytes(writer, MAX_SIZE); FileChunk readChunkA = fileSender.ReadChunk(_allocator); // then assertEquals(FileChunk.Create(chunkA, false), readChunkA); assertFalse(fileSender.EndOfInput); // when sbyte[] chunkC = WriteRandomBytes(writer, MAX_SIZE); FileChunk readChunkB = fileSender.ReadChunk(_allocator); // then assertEquals(FileChunk.Create(chunkB, false), readChunkB); assertFalse(fileSender.EndOfInput); // when FileChunk readChunkC = fileSender.ReadChunk(_allocator); assertEquals(FileChunk.Create(chunkC, true), readChunkC); // then assertTrue(fileSender.EndOfInput); assertNull(fileSender.ReadChunk(_allocator)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sendLargeFileWithUnreliableReadBufferSize() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SendLargeFileWithUnreliableReadBufferSize() { // given sbyte[] bytes = new sbyte[MAX_SIZE * 3]; _random.NextBytes(bytes); File smallFile = TestDirectory.file("smallFile"); using (StoreChannel storeChannel = _fs.create(smallFile)) { storeChannel.write(ByteBuffer.wrap(bytes)); } Adversary adversary = new RandomAdversary(0.9, 0.0, 0.0); AdversarialFileSystemAbstraction afs = new AdversarialFileSystemAbstraction(adversary, _fs); FileSender fileSender = new FileSender(new StoreResource(smallFile, null, 16, afs)); // when + then assertFalse(fileSender.EndOfInput); assertEquals(FileChunk.Create(copyOfRange(bytes, 0, MAX_SIZE), false), fileSender.ReadChunk(_allocator)); assertEquals(FileChunk.Create(copyOfRange(bytes, MAX_SIZE, MAX_SIZE * 2), false), fileSender.ReadChunk(_allocator)); assertEquals(FileChunk.Create(copyOfRange(bytes, MAX_SIZE * 2, bytes.Length), true), fileSender.ReadChunk(_allocator)); assertNull(fileSender.ReadChunk(_allocator)); assertTrue(fileSender.EndOfInput); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sendEmptyFile() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SendEmptyFile() { // given File emptyFile = TestDirectory.file("emptyFile"); _fs.create(emptyFile).close(); FileSender fileSender = new FileSender(new StoreResource(emptyFile, null, 16, _fs)); // when + then assertFalse(fileSender.EndOfInput); assertEquals(FileChunk.Create(new sbyte[0], true), fileSender.ReadChunk(_allocator)); assertNull(fileSender.ReadChunk(_allocator)); assertTrue(fileSender.EndOfInput); }
public override bool Equals(object o) { if (this == o) { return(true); } if (o == null || this.GetType() != o.GetType()) { return(false); } FileSender that = ( FileSender )o; return(Objects.Equals(_resource, that._resource)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sendEmptyFileWhichGrowsBeforeSendCommences() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SendEmptyFileWhichGrowsBeforeSendCommences() { // given File file = TestDirectory.file("file"); StoreChannel writer = _fs.create(file); FileSender fileSender = new FileSender(new StoreResource(file, null, 16, _fs)); // when sbyte[] bytes = WriteRandomBytes(writer, 1024); // then assertFalse(fileSender.EndOfInput); assertEquals(FileChunk.Create(bytes, true), fileSender.ReadChunk(_allocator)); assertTrue(fileSender.EndOfInput); assertNull(fileSender.ReadChunk(_allocator)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sendSmallFile() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SendSmallFile() { // given sbyte[] bytes = new sbyte[10]; _random.NextBytes(bytes); File smallFile = TestDirectory.file("smallFile"); using (StoreChannel storeChannel = _fs.create(smallFile)) { storeChannel.write(ByteBuffer.wrap(bytes)); } FileSender fileSender = new FileSender(new StoreResource(smallFile, null, 16, _fs)); // when + then assertFalse(fileSender.EndOfInput); assertEquals(FileChunk.Create(bytes, true), fileSender.ReadChunk(_allocator)); assertNull(fileSender.ReadChunk(_allocator)); assertTrue(fileSender.EndOfInput); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void sendLargeFileWithSizeMultipleOfTheChunkSize() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void SendLargeFileWithSizeMultipleOfTheChunkSize() { // given sbyte[] bytes = new sbyte[MAX_SIZE * 3]; _random.NextBytes(bytes); File smallFile = TestDirectory.file("smallFile"); using (StoreChannel storeChannel = _fs.create(smallFile)) { storeChannel.write(ByteBuffer.wrap(bytes)); } FileSender fileSender = new FileSender(new StoreResource(smallFile, null, 16, _fs)); // when + then assertFalse(fileSender.EndOfInput); assertEquals(FileChunk.Create(copyOfRange(bytes, 0, MAX_SIZE), false), fileSender.ReadChunk(_allocator)); assertEquals(FileChunk.Create(copyOfRange(bytes, MAX_SIZE, MAX_SIZE * 2), false), fileSender.ReadChunk(_allocator)); assertEquals(FileChunk.Create(copyOfRange(bytes, MAX_SIZE * 2, bytes.Length), true), fileSender.ReadChunk(_allocator)); assertNull(fileSender.ReadChunk(_allocator)); assertTrue(fileSender.EndOfInput); }