示例#1
0
        public void ExecuteExtensionMethod_OutputDeserialisation()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner <MySerialisableObject>(Method.POST, "/REST/vault/extensionmethod/HelloWorld.aspx");

            // Set the request body.
            var inputValue = new MySerialisableObject
            {
                a = "b",
                x = 7
            };

            runner.SetExpectedRequestBody(inputValue.ToSerializedString());

            // Set the response body.
            var outputValue = new MySerialisableObject
            {
                a = "c",
                x = 123
            };

            runner.ResponseData = outputValue;

            // Execute
            var output = runner.MFWSClient
                         .ExtensionMethodOperations
                         .ExecuteVaultExtensionMethod <MySerialisableObject, MySerialisableObject>("HelloWorld", input: inputValue);

            // Verify.
            runner.Verify();

            // Response must be correct.
            Assert.AreEqual(outputValue, output);
        }
示例#2
0
        public async Task ExecuteExtensionMethodAsync_InputSerialisation()
        {
            // Create our test runner.
            var runner = new RestApiTestRunner(Method.POST, "/REST/vault/extensionmethod/HelloWorld.aspx");

            // Set the request body.
            var inputValue = new MySerialisableObject
            {
                a = "b",
                x = 7
            };

            runner.SetExpectedRequestBody(inputValue.ToSerializedString());

            // 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);
        }