コード例 #1
0
        public void GetWorkflowStateTransitionIDByAlias()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <Dictionary <string, int> >(Method.POST, "/REST/structure/statetransitions/itemidbyalias.aspx");

            // Set up the expected body.
            var body = new JsonArray {
                "hello world"
            };

            runner.SetExpectedRequestBody(body);

            // Execute.
            runner.MFWSClient.WorkflowOperations.GetWorkflowStateTransitionIDByAlias("hello world");

            // Verify.
            runner.Verify();
        }
        public void GetObjectTypeIDsByAliases()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <Dictionary <string, int> >(Method.POST, "/REST/structure/objecttypes/itemidbyalias.aspx");

            // Set up the expected body.
            var body = new JsonArray {
                "hello", "world", "third option"
            };

            runner.SetExpectedRequestBody(body);

            // Execute.
            runner.MFWSClient.ObjectTypeOperations.GetObjectTypeIDsByAliases(aliases: new string[] { "hello", "world", "third option" });

            // Verify.
            runner.Verify();
        }
コード例 #3
0
        public async Task GetWorkflowStateTransitionIDsByAliasesAsync()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <Dictionary <string, int> >(Method.POST, "/REST/structure/statetransitions/itemidbyalias.aspx");

            // Set up the expected body.
            var body = new JsonArray {
                "hello", "world", "third option"
            };

            runner.SetExpectedRequestBody(body);

            // Execute.
            await runner.MFWSClient.WorkflowOperations.GetWorkflowStateTransitionIDsByAliasesAsync(aliases : new string[] { "hello", "world", "third option" });

            // Verify.
            runner.Verify();
        }
        public async Task GetObjectTypeIDByAliasAsync()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <Dictionary <string, int> >(Method.POST, "/REST/structure/objecttypes/itemidbyalias.aspx");

            // Set up the expected body.
            var body = new JsonArray {
                "hello world"
            };

            runner.SetExpectedRequestBody(body);

            // Execute.
            await runner.MFWSClient.ObjectTypeOperations.GetObjectTypeIDByAliasAsync("hello world");

            // Verify.
            runner.Verify();
        }
        public async Task GetPropertiesAsync_ExternalObject_SpecificVersion()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <List <PropertyValue> >(Method.GET, $"/REST/objects/0/umyrepository%3A12%2B3456/uabc%253A123/properties.aspx");

            // Execute.
            await runner.MFWSClient.ObjectPropertyOperations.GetPropertiesAsync(new ObjVer()
            {
                Type                              = 0,
                VersionType                       = MFObjVerVersionType.Latest,
                ExternalRepositoryName            = "myrepository",
                ExternalRepositoryObjectID        = "12 3456",          // NOTE: This will be double-encoded (" " to "+", then to "%2B").
                ExternalRepositoryObjectVersionID = "abc:123"           // NOTE: This will be double-encoded (":" to "%3A", then to "%253A").
            });

            // Verify.
            runner.Verify();
        }
コード例 #6
0
        public async Task GetExternalViewFolderAsync()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <FolderContentItems>(Method.GET, $"/REST/views/umyrepository%3A12%2B3456/items");

            // Execute.
            await runner.MFWSClient.ViewOperations.GetFolderContentsAsync(new FolderContentItem()
            {
                FolderContentItemType = MFFolderContentItemType.ExternalViewFolder,
                ExternalView          = new ExternalView()
                {
                    ExternalRepositoryName = "myrepository",
                    ID = "12 3456"                     // NOTE: This will be double-encoded (" " to "+", then to "%2B").
                }
            });

            // Verify.
            runner.Verify();
        }
コード例 #7
0
        public void GetViewContents_WithView()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <FolderContentItems>(Method.GET, $"/REST/views/v15/items");

            // Execute.
            runner.MFWSClient.ViewOperations.GetFolderContents(new FolderContentItem()
            {
                FolderContentItemType = MFFolderContentItemType.ViewFolder,
                View = new View()
                {
                    ID   = 15,
                    Name = "Favourites"
                }
            });

            // Verify.
            runner.Verify();
        }
コード例 #8
0
        public void SetWorkflowState()
        {
            var runner = new RestApiTestRunner <ExtendedObjectVersion>(Method.PUT, $"/REST/objects/0/1/2/workflowstate");

            runner.SetExpectedRequestBody(new ObjectWorkflowState()
            {
                StateID = 2
            });
            // Execute.
            runner.MFWSClient.ObjectPropertyOperations.SetWorkflowState(new ObjVer()
            {
                Type    = 0,
                ID      = 1,
                Version = 2
            }, 2);

            // Verify.
            runner.Verify();
        }
コード例 #9
0
        public void RenameFileWithVersionData()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <ObjectVersion>(Method.PUT, "/REST/objects/4/5/7/files/6/8/title");

            // Create the object to send in the body.
            var body = new PrimitiveType <string>()
            {
                Value = "renamed.pdf"
            };

            // Set the expected request body.
            runner.SetExpectedRequestBody(body);

            // Execute.
            runner.MFWSClient.ObjectFileOperations.RenameFile(4, 5, 6, "renamed.pdf", 7, 8);

            // Verify.
            runner.Verify();
        }
コード例 #10
0
        public async Task RenameFileAsync_WithVersionData()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <ObjectVersion>(Method.PUT, "/REST/objects/1/2/4/files/3/5/title");

            // Create the object to send in the body.
            var body = new PrimitiveType <string>()
            {
                Value = "renamed.pdf"
            };

            // Set the expected request body.
            runner.SetExpectedRequestBody(body);

            // Execute.
            await runner.MFWSClient.ObjectFileOperations.RenameFileAsync(1, 2, 3, "renamed.pdf", 4, 5);

            // Verify.
            runner.Verify();
        }
コード例 #11
0
        public void DownloadFile_Unmanaged()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner(Method.GET, "/REST/objects/0/umy%2Brepository%3Amy%2Bobject/uversion%2B1/files/umy%2Bfile/content");

            // Execute.
            runner.MFWSClient.ObjectFileOperations.DownloadFile(new ObjVer()
            {
                Type = 0,
                ExternalRepositoryName            = "my repository",      // Will be double-encoded.
                ExternalRepositoryObjectID        = "my object",          // Will be double-encoded.
                ExternalRepositoryObjectVersionID = "version 1"           // Will be double-encoded.
            }, new FileVer()
            {
                ExternalRepositoryFileID = "my file"                 // Will be double-encoded.
            });

            // Verify.
            runner.Verify();
        }
コード例 #12
0
        public void AddToFavorites()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <ExtendedObjectVersion>(Method.POST, $"/REST/favorites");

            // Set the expected body.
            var objId = new ObjID()
            {
                Type = 0,
                ID   = 1
            };

            runner.SetExpectedRequestBody(objId);

            // Execute.
            runner.MFWSClient.ObjectOperations.AddToFavorites(objId);

            // Verify.
            runner.Verify();
        }
        public async Task AddValueListItemByNameAsync()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <ValueListItem>(Method.POST, "/REST/valuelists/1/items");

            // Set the expected body.
            var newVLitem = new ValueListItem
            {
                ValueListID = 1,
                Name        = "new valuelistItem name"
            };

            runner.SetExpectedRequestBody(newVLitem);

            // Execute.
            await runner.MFWSClient.ValueListItemOperations.AddValueListItemAsync(1, "new valuelistItem name");

            // Verify.
            runner.Verify();
        }
コード例 #14
0
        public void GetViewContents_WithView_TwoGroupings()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <FolderContentItems>(Method.GET, $"/REST/views/v216/L4/L19/items");

            // Execute.
            runner.MFWSClient.ViewOperations.GetFolderContents(new FolderContentItem()
            {
                FolderContentItemType = MFFolderContentItemType.ViewFolder,
                View = new View()
                {
                    ID   = 216,
                    Name = "By Technology"
                }
            }, new FolderContentItem()
            {
                FolderContentItemType = MFFolderContentItemType.PropertyFolder,
                PropertyFolder        = new TypedValue()
                {
                    DataType = MFDataType.Lookup,
                    Lookup   = new Lookup()
                    {
                        Item = 4
                    }
                }
            }, new FolderContentItem()
            {
                FolderContentItemType = MFFolderContentItemType.PropertyFolder,
                PropertyFolder        = new TypedValue()
                {
                    DataType = MFDataType.Lookup,
                    Lookup   = new Lookup()
                    {
                        Item = 19
                    }
                }
            });

            // Verify.
            runner.Verify();
        }
コード例 #15
0
        public async Task GetPropertiesOfMultipleObjectsAsync_ExceptionForNoVersion()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <List <List <PropertyValue> > >(Method.POST, "/REST/objects/properties.aspx");

            // Create the object to send in the body.
            var body = new ObjVer()
            {
                ID   = 2,
                Type = 1
            };

            // We should post a collection of objvers (but only with this one in it).
            runner.SetExpectedRequestBody(new[] { body });

            // Execute.
            await runner.MFWSClient.ObjectPropertyOperations.GetPropertiesOfMultipleObjectsAsync(body);

            // Verify.
            runner.Verify();
        }
コード例 #16
0
        public void SetCheckoutStatus_CheckedOutToMe()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <ObjectVersion>(Method.PUT, $"/REST/objects/0/1/latest/checkedout");

            // Set the expected body.
            runner.SetExpectedRequestBody(new PrimitiveType <MFCheckOutStatus>()
            {
                Value = MFCheckOutStatus.CheckedOutToMe
            });

            // Execute.
            runner.MFWSClient.ObjectOperations.SetCheckoutStatus(new ObjID()
            {
                Type = 0,
                ID   = 1
            }, MFCheckOutStatus.CheckedOutToMe);

            // Verify.
            runner.Verify();
        }
コード例 #17
0
        public async Task GetAutomaticMetadataForTemporaryFilesAsync()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <List <PropertyValueSuggestion> >(Method.POST, "/REST/objects/automaticmetadata.aspx");

            // Set up the expected body.
            var body = new AutomaticMetadataRequestInfo()
            {
                UploadIds = new List <int>()
                {
                    123, 456
                }
            };

            runner.SetExpectedRequestBody(body);

            // Execute.
            await runner.MFWSClient.AutomaticMetadataOperations.GetAutomaticMetadataForTemporaryFilesAsync(temporaryFileIds : body.UploadIds.ToArray());

            // Verify.
            runner.Verify();
        }
コード例 #18
0
        public void SetCheckoutStatus_External_Latest()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <ObjectVersion>(Method.PUT, $"/REST/objects/0/urepository%2Bname%3Amy%2Bobject/latest/checkedout");

            // Set the expected body.
            runner.SetExpectedRequestBody(new PrimitiveType <MFCheckOutStatus>()
            {
                Value = MFCheckOutStatus.CheckedOutToMe
            });

            // Execute.
            runner.MFWSClient.ObjectOperations.SetCheckoutStatus(new ObjVer()
            {
                Type = 0,
                ExternalRepositoryName     = "repository name",
                ExternalRepositoryObjectID = "my object"
            }, MFCheckOutStatus.CheckedOutToMe);

            // Verify.
            runner.Verify();
        }
コード例 #19
0
        public async Task RenameObjectAsync()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <ObjectVersion>(Method.PUT, $"/REST/objects/1/2/latest/title");

            // Set the expected body.
            var newObjectName = new PrimitiveType <string>()
            {
                Value = "renamed object"
            };

            runner.SetExpectedRequestBody(newObjectName);

            // Execute.
            await runner.MFWSClient.ObjectOperations.RenameObjectAsync(new ObjID()
            {
                Type = 1,
                ID   = 2
            }, newObjectName.Value);

            // Verify.
            runner.Verify();
        }
コード例 #20
0
        public async Task LogInWithExtensionAuthenticationAsync()
        {
            // Set the target ID.
            var targetID = "hello world";

            // Create our test runner.
            var runner = new RestApiTestRunner <RepositoryAuthenticationStatus>(Method.POST, $"/REST/repositories/{HttpUtility.UrlEncode(targetID)}/session.aspx");

            // Create the body.
            var authentication = new RepositoryAuthentication()
            {
                ConfigurationName = "hello"
            };

            // Set the expected body.
            runner.SetExpectedRequestBody(authentication);

            // Execute.
            await runner.MFWSClient.ExtensionAuthenticationOperations.LogInWithExtensionAuthenticationAsync(targetID, authentication);

            // Verify.
            runner.Verify();
        }
コード例 #21
0
        public async Task AuthenticateUsingCredentialsAsync()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <PrimitiveType <string> >(Method.POST, "/REST/server/authenticationtokens");

            // When the execute method is called, return a dummy authentication token.
            runner.ResponseData = new PrimitiveType <string>()
            {
                Value = "hello world"
            };

            // Create the object to send in the body.
            var body = new Authentication
            {
                VaultGuid  = Guid.NewGuid(),
                Username   = "******",
                Password   = "******",
                SessionID  = "mySessionId",
                Expiration = new DateTime(2017, 01, 01, 0, 0, 0, DateTimeKind.Utc)
            };

            runner.SetExpectedRequestBody(body);

            // Execute.
            await runner.MFWSClient.AuthenticateUsingCredentialsAsync(body.VaultGuid.Value, body.Username, body.Password, body.Expiration.Value, body.SessionID);

            // Verify.
            runner.Verify();

            // Authentication header must exist.
            var authenticationHeader = runner.MFWSClient
                                       .DefaultParameters
                                       .FirstOrDefault(h => h.Type == ParameterType.HttpHeader && h.Name == "X-Authentication");

            Assert.IsNotNull(authenticationHeader);
            Assert.AreEqual("hello world", authenticationHeader.Value);
        }
コード例 #22
0
        public async Task ExecuteExtensionMethodAsync_CorrectOutput()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner(Method.POST, "/REST/vault/extensionmethod/HelloWorld.aspx");

            // Set the request body.
            const string inputValue = "this is my test input value";

            runner.SetExpectedRequestBody(inputValue);

            // Set the response body.
            const string outputValue = "Return value";

            runner.ResponseData = outputValue;

            // Execute.
            var output = await runner.MFWSClient.ExtensionMethodOperations.ExecuteVaultExtensionMethodAsync("HelloWorld", input : inputValue);

            // Verify.
            runner.Verify();

            // Response body must be correct.
            Assert.AreEqual(outputValue, output);
        }
コード例 #23
0
        public async Task RenameObjectAsync_Unmanaged_Latest()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <ObjectVersion>(Method.PUT, $"/REST/objects/0/uhello%3Aworld/latest/title");

            // Set the expected body.
            var newObjectName = new PrimitiveType <string>()
            {
                Value = "renamed object"
            };

            runner.SetExpectedRequestBody(newObjectName);

            // Execute.
            await runner.MFWSClient.ObjectOperations.RenameObjectAsync(new ObjID()
            {
                Type = 0,
                ExternalRepositoryName     = "hello",
                ExternalRepositoryObjectID = "world"
            }, newObjectName.Value);

            // Verify.
            runner.Verify();
        }
        public void DemoteObject()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <List <ExtendedObjectVersion> >(Method.PUT, "/REST/objects/demotemultiobjects");

            // Create the expected body.
            var body = new[]
            {
                new ObjID()
                {
                    Type = 0,
                    ID   = 123
                }
            };

            // Set the expected body.
            runner.SetExpectedRequestBody(body);

            // Execute.
            runner.MFWSClient.ExternalObjectOperations.DemoteObject(body[0]);

            // Verify.
            runner.Verify();
        }
コード例 #25
0
        public async Task SetPropertyAsync()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <ExtendedObjectVersion>(Method.PUT, "/REST/objects/1/2/latest/properties/0");

            // Create the object to send in the body.
            var body = new PropertyValue()
            {
                PropertyDef = 0,
                TypedValue  = new TypedValue()
                {
                    DataType = MFDataType.Text,
                    Value    = "hello world"
                }
            };

            runner.SetExpectedRequestBody(body);

            // Execute.
            await runner.MFWSClient.ObjectPropertyOperations.SetPropertyAsync(1, 2, body);

            // Verify.
            runner.Verify();
        }
コード例 #26
0
        public void GetAutomaticMetadataForObject()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <List <PropertyValueSuggestion> >(Method.POST, "/REST/objects/automaticmetadata.aspx");

            // Set up the expected body.
            var body = new AutomaticMetadataRequestInfo()
            {
                ObjVer = new ObjVer()
                {
                    Type    = 0,
                    ID      = 43,
                    Version = 0
                }
            };

            runner.SetExpectedRequestBody(body);

            // Execute.
            runner.MFWSClient.AutomaticMetadataOperations.GetAutomaticMetadataForObject(body.ObjVer);

            // Verify.
            runner.Verify();
        }
        public async Task PromoteObjectsAsync()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <List <ExtendedObjectVersion> >(Method.PUT, "/REST/objects/setmultipleobjproperties");

            // Create the expected body.
            var body = new ObjectsUpdateInfo()
            {
                MultipleObjectInfo = new[]
                {
                    new ObjectVersionUpdateInformation()
                    {
                        ObjVer = new ObjVer()
                        {
                            ExternalRepositoryName            = "hello world",
                            ExternalRepositoryObjectID        = "my object id",
                            ExternalRepositoryObjectVersionID = "version",
                            Type = 0
                        },
                        Properties = new List <PropertyValue>
                        {
                            new PropertyValue()
                            {
                                PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass,
                                TypedValue  = new TypedValue()
                                {
                                    Lookup = new Lookup()
                                    {
                                        Item = (int)MFBuiltInDocumentClass.MFBuiltInDocumentClassOtherDocument
                                    }
                                }
                            }
                        }
                    },
                    new ObjectVersionUpdateInformation()
                    {
                        ObjVer = new ObjVer()
                        {
                            ExternalRepositoryName            = "hello world",
                            ExternalRepositoryObjectID        = "my object id 2",
                            ExternalRepositoryObjectVersionID = "version 2",
                            Type = 0
                        },
                        Properties = new List <PropertyValue>
                        {
                            new PropertyValue()
                            {
                                PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass,
                                TypedValue  = new TypedValue()
                                {
                                    Lookup = new Lookup()
                                    {
                                        Item = (int)MFBuiltInDocumentClass.MFBuiltInDocumentClassOtherDocument
                                    }
                                }
                            }
                        }
                    }
                }.ToList()
            };

            // Set the expected body.
            runner.SetExpectedRequestBody(body);

            // Execute.
            await runner.MFWSClient.ExternalObjectOperations.PromoteObjectsAsync(
                objectVersionUpdateInformation : body.MultipleObjectInfo.ToArray());

            // Verify.
            runner.Verify();
        }
コード例 #28
0
        public void SetPropertiesOfMultipleObjects()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <List <ExtendedObjectVersion> >(Method.PUT, "/REST/objects/setmultipleobjproperties");

            // Create the expected body.
            var body = new ObjectsUpdateInfo()
            {
                MultipleObjectInfo = new[]
                {
                    new ObjectVersionUpdateInformation()
                    {
                        ObjVer = new ObjVer()
                        {
                            Type    = 0,
                            ID      = 1,
                            Version = 2
                        },
                        Properties = new List <PropertyValue>
                        {
                            new PropertyValue()
                            {
                                PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass,
                                TypedValue  = new TypedValue()
                                {
                                    Lookup = new Lookup()
                                    {
                                        Item = (int)MFBuiltInDocumentClass.MFBuiltInDocumentClassOtherDocument
                                    }
                                }
                            }
                        }
                    },
                    new ObjectVersionUpdateInformation()
                    {
                        ObjVer = new ObjVer()
                        {
                            Type    = 0,
                            ID      = 2,
                            Version = 1
                        },
                        Properties = new List <PropertyValue>
                        {
                            new PropertyValue()
                            {
                                PropertyDef = (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefClass,
                                TypedValue  = new TypedValue()
                                {
                                    Lookup = new Lookup()
                                    {
                                        Item = (int)MFBuiltInDocumentClass.MFBuiltInDocumentClassOtherDocument
                                    }
                                }
                            }
                        }
                    }
                }.ToList()
            };

            // Set the expected body.
            runner.SetExpectedRequestBody(body);

            // Execute.
            runner.MFWSClient.ExternalObjectOperations.PromoteObjects(
                objectVersionUpdateInformation: body.MultipleObjectInfo.ToArray());

            // Verify.
            runner.Verify();
        }