in AdlsDotNetSDKUnitTest/SdkUnitTest.cs [1559:1628]
public void TestConcatThreeFile(bool deleteSource, string destPath, string sourcePath)
{
List<string> srcList = new List<string>();
string srcFile1 = sourcePath + "/srcPath3.txt";
string text1 = RandomString(1024);
byte[] textByte1 = Encoding.UTF8.GetBytes(text1);
using (var ostream = _adlsClient.CreateFile(srcFile1, IfExists.Overwrite, ""))
{
ostream.Write(textByte1, 0, textByte1.Length);
}
string srcFile2 = sourcePath + "/srcPath4.txt";
string text2 = RandomString(5 * 1024 * 1024);
byte[] textByte2 = Encoding.UTF8.GetBytes(text2);
using (var ostream = _adlsClient.CreateFile(srcFile2, IfExists.Overwrite, ""))
{
ostream.Write(textByte2, 0, textByte2.Length);
}
string srcFile3 = sourcePath + "/srcPath5.txt";
string text3 = RandomString(300 * 1024);
byte[] textByte3 = Encoding.UTF8.GetBytes(text3);
using (var ostream = _adlsClient.CreateFile(srcFile3, IfExists.Overwrite, ""))
{
ostream.Write(textByte3, 0, textByte3.Length);
}
srcList.Add(srcFile1);
srcList.Add(srcFile2);
srcList.Add(srcFile3);
_adlsClient.ConcatenateFiles(destPath, srcList, deleteSource);
string output = "";
using (var istream = _adlsClient.GetReadStream(destPath))
{
int noOfBytes;
byte[] buffer = new byte[8 * 1024 * 1024];
do
{
noOfBytes = istream.Read(buffer, 0, buffer.Length);
output += Encoding.UTF8.GetString(buffer, 0, noOfBytes);
} while (noOfBytes > 0);
}
Assert.IsTrue(output.Equals(text1 + text2 + text3));
try
{
_adlsClient.GetDirectoryEntry(srcFile1);
Assert.Fail("The file should have been deleted so GetFileStatus should throw an exception");
}
catch (IOException) { }
try
{
_adlsClient.GetDirectoryEntry(srcFile2);
Assert.Fail("The file should have been deleted so GetFileStatus should throw an exception");
}
catch (IOException) { }
try
{
_adlsClient.GetDirectoryEntry(srcFile3);
Assert.Fail("The file should have been deleted so GetFileStatus should throw an exception");
}
catch (IOException) { }
if (deleteSource)
{
try
{
_adlsClient.GetDirectoryEntry($"{UnitTestDir}/Source");
Assert.Fail("The directory should have been deleted so GetFileStatus should throw an exception");
}
catch (IOException) { }
}
}