示例#1
0
        public async Task DeleteFolderTest()
        {
            var provider  = new FileSystemProvider(BaseDir);
            var filename1 = "testfolder\\" + Path.GetRandomFileName();
            var filename2 = "testfolder\\" + Path.GetRandomFileName();
            await provider.AddFile(RandomFileGenerator.RandomFileByteArray(1000), filename1);

            await provider.AddFile(RandomFileGenerator.RandomFileByteArray(2000), filename2);

            var result = await provider.DeleteFolder("testfolder");

            Assert.IsTrue(result);
            Assert.IsFalse(await provider.FileExists(filename1));
            Assert.IsFalse(await provider.FileExists(filename2));
        }
示例#2
0
        public async Task GetBytesTest()
        {
            var provider = new FileSystemProvider(BaseDir);
            var filename = Path.GetRandomFileName();
            var add      = await provider.AddFile(RandomFileGenerator.RandomFileByteArray(1000), filename);

            Assert.IsTrue(await provider.FileExists(filename));
        }
示例#3
0
        public async Task AddStreamTest()
        {
            var provider = new FileSystemProvider(BaseDir); var filename = Path.GetRandomFileName();

            using (var stream = new MemoryStream(RandomFileGenerator.RandomFileByteArray(1000)))
            {
                var add = await provider.AddFile(stream, filename);

                Assert.IsTrue(add);
                Assert.IsTrue(await provider.FileExists(filename));
            }
        }
示例#4
0
        public async Task GetStreamTest()
        {
            var provider = new FileSystemProvider(BaseDir);
            var filename = Path.GetRandomFileName();
            var add      = await provider.AddFile(RandomFileGenerator.RandomFileByteArray(1000), filename);

            using (MemoryStream stream = new MemoryStream())
            {
                await provider.DownloadStream(stream, filename);

                Assert.IsTrue(stream.Length == 999);//file storage size is 999 for 1000 bytes
            }
        }
示例#5
0
        public async Task GetFileTest()
        {
            var provider       = new FileSystemProvider(BaseDir);
            var filename       = Path.GetRandomFileName();
            var outputFileName = Path.GetTempFileName();
            var add            = await provider.AddFile(RandomFileGenerator.RandomFileByteArray(1000), filename);

            await provider.DownloadToFile(filename, outputFileName, true);//overdie if exists since gettempfileme creates the file

            var file = File.ReadAllBytes(outputFileName);

            Assert.IsTrue(await provider.FileExists(filename));
            File.Delete(outputFileName);
        }
示例#6
0
        public async Task AddFileTest()
        {
            var provider = new FileSystemProvider(BaseDir);
            var filename = Path.GetRandomFileName();
            var tempFile = Path.GetTempFileName();

            using (var file = File.OpenWrite(tempFile))
            {
                await file.WriteAsync(RandomFileGenerator.RandomFileByteArray(1000), 0, 1000);
            }

            var add = await provider.AddFile(tempFile, filename);

            Assert.IsTrue(add);
            Assert.IsTrue(await provider.FileExists(filename));
        }