Ejemplo n.º 1
0
        public void TestDownloadFileToStream()
        {
            var fileName   = "UploadTest.txt";
            var content    = "MyTestContent";
            var sourcePath = "/";

            var api = new MailRuCloud()
            {
                Account = account
            };

            var result = new MemoryStream(api.GetFile(new MailRuCloudApi.File(fileName, sourcePath + fileName), false).Result);

            using (var streamReader = new StreamReader(result))
                Assert.AreEqual(content, streamReader.ReadToEnd());
        }
Ejemplo n.º 2
0
        public void TestDownloadBinaryFileToStream()
        {
            var fileName   = "UploadTestBinary.bin";
            var content    = Enumerable.Range(0, 256).Select(i => (byte)i).ToArray();
            var sourcePath = "/";

            var api = new MailRuCloud()
            {
                Account = account
            };

            var result = new MemoryStream(api.GetFile(new MailRuCloudApi.File(fileName, sourcePath + fileName), false).Result);

            var output = new byte[result.Length];

            result.Read(output, 0, (int)result.Length);
            CollectionAssert.AreEqual(content, output);
        }