in AdlsDotNetSDKUnitTest/SdkUnitTest.cs [859:910]
public void TestSeekCurrentBack()
{
string path = $"{UnitTestDir}/testSeekCurrentBack.txt";
int strLength = 12 * 1024 * 1024;
string text1 = RandomString(strLength);
int readTill = strLength / 2;
byte[] textByte1 = Encoding.UTF8.GetBytes(text1);
using (var ostream = _adlsClient.CreateFile(path, IfExists.Overwrite, ""))
{
ostream.Write(textByte1, 0, textByte1.Length);
}
string expectedOp = "";
string actualOp = "";
using (var istream = _adlsClient.GetReadStream(path))
{
byte[] buff = new byte[strLength];
int totalBytes = 0, startBytes = 0;
int noBytes;
int totalLengthToRead = readTill - startBytes;
do
{
noBytes = istream.Read(buff, 0, totalLengthToRead);
actualOp += Encoding.UTF8.GetString(buff, 0, noBytes);
totalBytes += noBytes;
totalLengthToRead -= noBytes;
} while (noBytes > 0 && totalLengthToRead > 0);
expectedOp += text1.Substring(startBytes, totalBytes - startBytes);
istream.Seek(-1 * strLength / 4, SeekOrigin.Current);
startBytes = totalBytes = strLength / 4;
totalLengthToRead = 3 * readTill / 2 - startBytes;
do
{
noBytes = istream.Read(buff, 0, totalLengthToRead);
actualOp += Encoding.UTF8.GetString(buff, 0, noBytes);
totalBytes += noBytes;
totalLengthToRead -= noBytes;
} while (noBytes > 0 && totalLengthToRead > 0);
expectedOp += text1.Substring(startBytes, totalBytes - startBytes);
istream.Seek(-1 * strLength / 4, SeekOrigin.Current);
startBytes = totalBytes = strLength / 2;
totalLengthToRead = 2 * readTill - startBytes;
do
{
noBytes = istream.Read(buff, 0, totalLengthToRead);
actualOp += Encoding.UTF8.GetString(buff, 0, noBytes);
totalBytes += noBytes;
totalLengthToRead -= noBytes;
} while (noBytes > 0 && totalLengthToRead > 0);
expectedOp += text1.Substring(startBytes, totalBytes - startBytes);
}
Assert.IsTrue(actualOp.Equals(expectedOp));
}