public void TestConcatTwoFile()

in AdlsDotNetSDKUnitTest/SdkUnitTest.cs [1488:1541]


        public void TestConcatTwoFile(bool deleteSource, string destPath, string sourcePath, string sourceFileNamePrefix = "")
        {
            List<string> srcList = new List<string>();
            string srcFile1 = sourcePath + "/" + sourceFileNamePrefix + "srcPath1.txt";
            string text1 = RandomString(2 * 1024 * 1024);
            byte[] textByte1 = Encoding.UTF8.GetBytes(text1);
            using (var ostream = _adlsClient.CreateFile(srcFile1, IfExists.Overwrite, ""))
            {
                ostream.Write(textByte1, 0, textByte1.Length);
            }
            string srcFile2 = sourcePath + "/" + sourceFileNamePrefix + "srcPath2.txt";
            string text2 = RandomString(3 * 1024 * 1024);
            byte[] textByte2 = Encoding.UTF8.GetBytes(text2);
            using (var ostream = _adlsClient.CreateFile(srcFile2, IfExists.Overwrite, ""))
            {
                ostream.Write(textByte2, 0, textByte2.Length);
            }
            srcList.Add(srcFile1);
            srcList.Add(srcFile2);
            _adlsClient.ConcatenateFiles(destPath, srcList, deleteSource);
            string output = "";
            using (var istream = _adlsClient.GetReadStream(destPath))
            {
                int noOfBytes;
                byte[] buffer = new byte[5 * 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));
            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) { }
            if (deleteSource)
            {
                try
                {
                    _adlsClient.GetDirectoryEntry(sourcePath);
                    Assert.Fail("The directory should have been deleted so Getfilestatus should throw an exception");
                }
                catch (IOException) { }
            }
        }