示例#1
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();
        }
示例#2
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   = "******",
                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);

            // 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);
        }
示例#3
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);
        }
        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();
        }
示例#5
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();
        }
        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();
        }