Пример #1
0
        public void TestPutFile()
        {
            string localFilePath  = Path.GetTempFileName();
            string remoteFilePath = "/uprof/testputfile.txt";
            string contents       = "12345678901234567890123456789012345678901234567890123456789012345678901234567890";

            using (FileStream fs = File.Create(localFilePath, contents.Length))
            {
                fs.Write(System.Text.UTF8Encoding.UTF8.GetBytes(contents), 0, contents.Length);
            }

            xmlmcService.PutFile(localFilePath, remoteFilePath);

            File.Delete(localFilePath);
            Assert.IsTrue(xmlmcService.DoesFileExists(remoteFilePath));
            string fileContents = xmlmcService.GetFileContents(remoteFilePath);

            Assert.IsTrue(contents.CompareTo(fileContents) == 0);
            MemoryStream memoryStream;

            xmlmcService.GetFile(remoteFilePath, out memoryStream);
            if (memoryStream != null)
            {
                fileContents = System.Text.UTF8Encoding.UTF8.GetString(memoryStream.ToArray());
                Assert.IsTrue(contents.CompareTo(fileContents) == 0);
                memoryStream.Close();
            }
            xmlmcService.RemoveFile(remoteFilePath);
        }