示例#1
0
        public async Task UploadFileAsync_Unmanaged()
        {
            // Create our test runner.
            var runner = new FileRestApiTestRunner <ExtendedObjectVersion>(Method.PUT, "/REST/objects/0/umy%2Brepository%3Amy%2Bobject/uversion%2B1/files/umy%2Bfile/content.aspx");

            // Create a temporary file.
            var tempFile = new FileInfo(@"test.txt");

            if (false == tempFile.Exists)
            {
                tempFile.Create();

                // NOTE: If test.txt did not exist the first time the test was run then 'file.Length' will throw an exception
                // of type 'System.IO.FileNotFoundException' in MFWSVaultObjectFileOperations.UploadFilesAsync.
                tempFile = new FileInfo(@"test.txt");
            }

            // Execute.
            await runner.MFWSClient.ObjectFileOperations.UploadFileAsync(new ObjVer()
            {
                Type = 0,
                ExternalRepositoryName            = "my repository",
                ExternalRepositoryObjectID        = "my object",
                ExternalRepositoryObjectVersionID = "version 1"
            }, new FileVer()
            {
                ExternalRepositoryFileID        = "my file",
                ExternalRepositoryFileVersionID = "version 2"
            }, tempFile.FullName);

            // Verify.
            runner.Verify();

            // Ensure the file data was passed.
            Assert.IsNotNull(runner.RequestFiles);
            Assert.AreEqual(1, runner.RequestFiles.Count);
            Assert.AreEqual(tempFile.Name, runner.RequestFiles[0].Name);
            Assert.AreEqual(tempFile.Length, runner.RequestFiles[0].ContentLength);
        }
示例#2
0
        public void UploadFiles()
        {
            // Create our test runner.
            var runner = new FileRestApiTestRunner <List <UploadInfo> >(Method.POST, "/REST/files.aspx");

            // Create a temporary file.
            var tempFile = new FileInfo(@"test.txt");

            if (false == tempFile.Exists)
            {
                tempFile.Create();

                // NOTE: If test.txt did not exist the first time the test was run then 'file.Length' will throw an exception
                // of type 'System.IO.FileNotFoundException' in MFWSVaultObjectFileOperations.UploadFiles.
                tempFile = new FileInfo(@"test.txt");
            }

            // When the execute method is called, return dummy upload information.
            runner.ResponseData = new[]
            {
                new UploadInfo()
                {
                    UploadID = 1
                }
            }.ToList();

            // Execute.
            runner.MFWSClient.ObjectFileOperations.UploadFiles(tempFile);

            // Verify.
            runner.Verify();

            // Ensure the file data was passed.
            Assert.IsNotNull(runner.RequestFiles);
            Assert.AreEqual(1, runner.RequestFiles.Count);
            Assert.AreEqual(tempFile.Name, runner.RequestFiles[0].Name);
            Assert.AreEqual(tempFile.Length, runner.RequestFiles[0].ContentLength);
        }
示例#3
0
        public async Task UploadFileAsync()
        {
            // Create our test runner.
            var runner = new FileRestApiTestRunner <ExtendedObjectVersion>(Method.PUT, "/REST/objects/456/123/9/files/123/content.aspx");

            // Create a temporary file.
            var tempFile = new FileInfo(@"test.txt");

            if (false == tempFile.Exists)
            {
                tempFile.Create();

                // NOTE: If test.txt did not exist the first time the test was run then 'file.Length' will throw an exception
                // of type 'System.IO.FileNotFoundException' in MFWSVaultObjectFileOperations.UploadFilesAsync.
                tempFile = new FileInfo(@"test.txt");
            }

            // Execute.
            await runner.MFWSClient.ObjectFileOperations.UploadFileAsync(new ObjVer()
            {
                Type    = 456,
                ID      = 123,
                Version = 9
            }, new FileVer()
            {
                ID = 123
            }, tempFile.FullName);

            // Verify.
            runner.Verify();

            // Ensure the file data was passed.
            Assert.IsNotNull(runner.RequestFiles);
            Assert.AreEqual(1, runner.RequestFiles.Count);
            Assert.AreEqual(tempFile.Name, runner.RequestFiles[0].Name);
            Assert.AreEqual(tempFile.Length, runner.RequestFiles[0].ContentLength);
        }