Exemplo n.º 1
0
    public static void MessageContract_ContractDescription_MessageHeaders()
    {
        // -----------------------------------------------------------------------------------------------
        // IMessageContract_4_4_0:
        //    This service exposes a single operation that uses MessageContract.
        //    This contract uses attributes added to the public API only after 1.1.0
        //    (MessageHeaderArrayAttribute and MessageProperty)
        // -----------------------------------------------------------------------------------------------
        string results = ContractDescriptionTestHelper.ValidateContractDescription <IMessageContract_4_4_0>(new ContractDescriptionData
        {
            Operations = new OperationDescriptionData[]
            {
                new OperationDescriptionData
                {
                    Name     = TestTypeConstants_4_4_0.MessageContract_RequestReply_OperationName,
                    IsOneWay = false,
                    HasTask  = false,
                    Messages = new MessageDescriptionData[]
                    {
                        // The request message description
                        new MessageDescriptionData
                        {
                            Action      = TestTypeConstants_4_4_0.MessageContract_Request_Action,
                            Direction   = MessageDirection.Input,
                            MessageType = typeof(RequestBankingData_4_4_0),
                            Body        = new PartDescriptionData[]
                            {
                                new PartDescriptionData {
                                    Name     = TestTypeConstants_4_4_0.MessageContract_Request_TransactionDateName,
                                    Type     = typeof(DateTime),
                                    Multiple = false
                                },
                                new PartDescriptionData {
                                    Name     = TestTypeConstants_4_4_0.MessageContract_Request_CustomerName,
                                    Type     = typeof(string),
                                    Multiple = false
                                }
                            },
                            Headers = new PartDescriptionData[]
                            {
                                new PartDescriptionData {
                                    Name     = TestTypeConstants_4_4_0.MessageContract_Request_SingleValueName,
                                    Type     = typeof(string),
                                    Multiple = false
                                },
                                new PartDescriptionData {
                                    Name     = TestTypeConstants_4_4_0.MessageContract_Request_MultipleValueName,
                                    Type     = typeof(string[]),
                                    Multiple = false
                                },
                                new PartDescriptionData {
                                    Name     = TestTypeConstants_4_4_0.MessageContract_Request_MultipleArrayValueName,
                                    Type     = typeof(string),
                                    Multiple = true
                                },
                            },
                            Properties = new PartDescriptionData[]
                            {
                                new PartDescriptionData {
                                    Name     = TestTypeConstants_4_4_0.MessageContract_Request_PropertyName,
                                    Type     = null,
                                    Multiple = false
                                },
                            }
                        },

                        // The reply message description
                        new MessageDescriptionData
                        {
                            Action      = TestTypeConstants_4_4_0.MessageContract_Reply_Action,
                            Direction   = MessageDirection.Output,
                            MessageType = typeof(ReplyBankingData_4_4_0),
                            Body        = new PartDescriptionData[]
                            {
                                new PartDescriptionData {
                                    Name     = TestTypeConstants_4_4_0.MessageContract_Reply_TransactionDateName,
                                    Type     = typeof(DateTime),
                                    Multiple = false
                                },
                                new PartDescriptionData {
                                    Name     = TestTypeConstants_4_4_0.MessageContract_Reply_CustomerName,
                                    Type     = typeof(string),
                                    Multiple = false
                                },
                                new PartDescriptionData {
                                    Name     = TestTypeConstants_4_4_0.MessageContract_Reply_TransactionAmountName,
                                    Type     = typeof(decimal),
                                    Multiple = false
                                },
                            },
                            Headers = new PartDescriptionData[]
                            {
                                new PartDescriptionData {
                                    Name     = TestTypeConstants_4_4_0.MessageContract_Reply_SingleValueName,
                                    Type     = typeof(string),
                                    Multiple = false
                                },
                                new PartDescriptionData {
                                    Name     = TestTypeConstants_4_4_0.MessageContract_Reply_MultipleValueName,
                                    Type     = typeof(string[]),
                                    Multiple = false
                                },
                                new PartDescriptionData {
                                    Name     = TestTypeConstants_4_4_0.MessageContract_Reply_MultipleArrayValueName,
                                    Type     = typeof(string),
                                    Multiple = true
                                },
                            },
                            Properties = new PartDescriptionData[]
                            {
                                new PartDescriptionData {
                                    Name     = TestTypeConstants_4_4_0.MessageContract_Reply_PropertyName,
                                    Type     = null,
                                    Multiple = false
                                },
                            }
                        }
                    }
                }
            }
        });

        // Assert.True because results contains informative error failure
        Assert.True(results == null, results);
    }