示例#1
0
        public void ToQueryString_DefaultPathIsNull_DoesNotAppearInQueryString()
        {
            // Arrange
            var options = new MultiFileUploadOptions {
                DefaultPath = null
            };

            // Act
            var queryString = options.ToQueryString();

            // Assert
            Assert.That(!queryString.Contains("defaultpath", StringComparison.OrdinalIgnoreCase));
        }
示例#2
0
        public void ToQueryString_DryRunIsFalse_DoesNotAppearInQueryString()
        {
            // Arrange
            var options = new MultiFileUploadOptions {
                DryRun = false
            };

            // Act
            var queryString = options.ToQueryString();

            // Assert
            Assert.That(!queryString.Contains("dryrun", StringComparison.OrdinalIgnoreCase));
        }
示例#3
0
        public void ToQueryString_DisableDefaultPathIsTrue_AppearsInQueryString()
        {
            // Arrange
            var options = new MultiFileUploadOptions {
                DisableDefaultPath = true
            };

            // Act
            var queryString = options.ToQueryString();

            // Assert
            Assert.Multiple(() =>
            {
                Assert.That(queryString.StartsWith('?'));
                Assert.That(queryString.Contains("disabledefaultpath=true", StringComparison.OrdinalIgnoreCase));
            });
        }
示例#4
0
        public void ToQueryString_FileNameIsNull_AppearsAsDateTimeInQueryString()
        {
            // Arrange
            var options = new MultiFileUploadOptions {
                FileName = null
            };

            // Act
            var queryString = options.ToQueryString();

            // Assert
            Assert.Multiple(() =>
            {
                Assert.That(queryString.StartsWith('?'));
                Assert.That(Regex.IsMatch(queryString, @"filename=\d{4}-\d{2}-\d{2}%3A\d{2}-\d{2}-\d{2}"));
            });
        }
示例#5
0
        public void ToQueryString_FileNameIsSet_AppearsInQueryString()
        {
            // Arrange
            var options = new MultiFileUploadOptions {
                FileName = "allmyfiles"
            };

            // Act
            var queryString = options.ToQueryString();

            // Assert
            Assert.Multiple(() =>
            {
                Assert.That(queryString.StartsWith('?'));
                Assert.That(queryString.Contains($"filename=allmyfiles", StringComparison.OrdinalIgnoreCase));
            });
        }
示例#6
0
        public void ToQueryString_DefaultPathIsSet_AppearsInQueryString()
        {
            // Arrange
            var options = new MultiFileUploadOptions {
                DefaultPath = "www/index.html"
            };

            // Act
            var queryString = options.ToQueryString();

            // Assert
            Assert.Multiple(() =>
            {
                Assert.That(queryString.StartsWith('?'));
                Assert.That(queryString.Contains("defaultpath=www%2Findex.html", StringComparison.OrdinalIgnoreCase));
            });
        }
        public async Task UploadFiles_FromFileInfo_ExpectedSkylink()
        {
            // Arrange
            var files = new PhysicalFileInfo[]
            {
                new PhysicalFileInfo(new FileInfo("assets/test-file.json")),
                new PhysicalFileInfo(new FileInfo("assets/test-file.txt"))
            };

            var options = new MultiFileUploadOptions {
                FileName = "integration-tests"
            };

            // Act
            var skylink = await _skynetWebPortal.UploadFiles(files, options);

            // Assert
            Assert.That(skylink.ToString() == "AACVmVl_KyZTaaS2cdGANxedYtOGJu13urqfc_yQl5jL8w");
        }
        public async Task UploadDirectory_Recursive_ExpectedSkylink()
        {
            // Arrange
            var fileProvider = new InMemoryFileProvider();

            fileProvider.Directory.Root.AddFile(new StringFileInfo("this file exists", "exists.txt"));
            fileProvider.Directory.Root.AddFile(new StringFileInfo("file contents", "foo.txt"));
            fileProvider.Directory.GetOrAddFolder("foo").AddFile(new StringFileInfo("{ \"another\":\"file\" }", "bar.json"));

            var options = new MultiFileUploadOptions {
                FileName = "integration-tests"
            };

            // Act
            var skylink = await _skynetWebPortal.UploadDirectory(fileProvider, "", true, options);

            // Assert
            Assert.That(skylink.ToString() == "AACggsc6nihGIi-1rOhJbx2TJi3W30OgdQKPNr_9Kgfeog");
        }
        public async Task UploadDirectory_NonRecursive_ExpectedSkylink()
        {
            // Arrange
            var fileProvider = new InMemoryFileProvider();

            fileProvider.Directory.AddFile("", new StringFileInfo("this file exists", "exists.txt"));
            fileProvider.Directory.AddFile("", new StringFileInfo("file contents", "foo.txt"));
            fileProvider.Directory.AddFile("foo", new StringFileInfo("{ \"another\":\"file\" }", "bar.json"));

            var options = new MultiFileUploadOptions {
                FileName = "integration-tests"
            };

            // Act
            var skylink = await _skynetWebPortal.UploadDirectory(fileProvider, "", false, options);

            // Assert
            Assert.That(skylink.ToString() == "AABU1QK8EVh5O47wX2qYyXQrzgRu7sl_ty5lWluhVzEFCw");
        }
        public async Task UploadFiles_FromUploadItemsDifferentContentType_ExpectedSkylink()
        {
            // Arrange
            var fileOne = new PhysicalFileInfo(new FileInfo("assets/test-file.json"));
            var fileTwo = new PhysicalFileInfo(new FileInfo("assets/test-file.txt"));

            var items = new UploadItem[]
            {
                new UploadItem(fileOne, contentType: new MediaTypeHeaderValue("application/octet-stream")),
                new UploadItem(fileTwo, contentType: new MediaTypeHeaderValue("text/xml"))
            };

            var options = new MultiFileUploadOptions {
                FileName = "integration-tests"
            };

            // Act
            var skylink = await _skynetWebPortal.UploadFiles(items, options);

            // Assert
            Assert.That(skylink.ToString() == "AADOj5s9MWkkim6Py9suD0DDZWzddCB3ep8C0Vr9W8w9DQ");
        }
        public async Task UploadFiles_FromUploadItemsDifferentSkynetPath_ExpectedSkylink()
        {
            // Arrange
            var fileOne = new PhysicalFileInfo(new FileInfo("assets/test-file.json"));
            var fileTwo = new PhysicalFileInfo(new FileInfo("assets/test-file.txt"));

            var items = new UploadItem[]
            {
                new UploadItem(fileOne, skynetPath: "custom/directory/test-file.json"),
                new UploadItem(fileTwo, skynetPath: "custom/directory/foo/test-file.txt")
            };

            var options = new MultiFileUploadOptions {
                FileName = "integration-tests"
            };

            // Act
            var skylink = await _skynetWebPortal.UploadFiles(items, options);

            // Assert
            Assert.That(skylink.ToString() == "AADPKdb7S7E_Uvdy8kjeA4OoPG5HgTZgismv0Ys_BBLgrQ");
        }
 public AtawMultiFileUploadOptionCreator()
 {
     fBaseUploadOptions = new MultiFileUploadOptions();
     BaseOptions        = fBaseUploadOptions;
 }