public void SerializeToXml()
        {
            var wba = new WcfBasicHttpRelayAdapter.Inbound(
                a => {
                a.Address                        = new EndpointAddress("https://biztalk.factory.servicebus.windows.net/batch-queue");
                a.Identity                       = EndpointIdentityFactory.CreateSpnIdentity("spn_name");
                a.MaxConcurrentCalls             = 201;
                a.MaxReceivedMessageSize         = 64512;
                a.MessageEncoding                = WSMessageEncoding.Mtom;
                a.SuspendRequestMessageOnFailure = true;
                a.IncludeExceptionDetailInFaults = true;

                a.StsUri       = new Uri("https://biztalk.factory-sb.accesscontrol.windows.net/");
                a.IssuerName   = "issuer_name";
                a.IssuerSecret = "issuer_secret";

                a.EnableServiceDiscovery = true;
                a.ServiceDisplayName     = "display_name";
            });
            var xml = ((IAdapterBindingSerializerFactory)wba).GetAdapterBindingSerializer().Serialize();

            Assert.That(
                xml,
                Is.EqualTo(
                    "<CustomProps>" +
                    "<MaxReceivedMessageSize vt=\"3\">64512</MaxReceivedMessageSize>" +
                    "<MessageEncoding vt=\"8\">Mtom</MessageEncoding>" +
                    "<TextEncoding vt=\"8\">utf-8</TextEncoding>" +
                    "<SecurityMode vt=\"8\">Transport</SecurityMode>" +
                    "<MessageClientCredentialType vt=\"8\">UserName</MessageClientCredentialType>" +
                    "<AlgorithmSuite vt=\"8\">Basic256</AlgorithmSuite>" +
                    "<RelayClientAuthenticationType vt=\"8\">RelayAccessToken</RelayClientAuthenticationType>" +
                    "<UseSSO vt=\"11\">0</UseSSO>" +
                    "<MaxConcurrentCalls vt=\"3\">201</MaxConcurrentCalls>" +
                    "<InboundBodyLocation vt=\"8\">UseBodyElement</InboundBodyLocation>" +
                    "<InboundNodeEncoding vt=\"8\">Xml</InboundNodeEncoding>" +
                    "<OutboundBodyLocation vt=\"8\">UseBodyElement</OutboundBodyLocation>" +
                    "<OutboundXmlTemplate vt=\"8\">" + (
                        "&lt;bts-msg-body xmlns=\"http://www.microsoft.com/schemas/bts2007\" encoding=\"xml\"/&gt;") +
                    "</OutboundXmlTemplate>" +
                    "<SuspendMessageOnFailure vt=\"11\">-1</SuspendMessageOnFailure>" +
                    "<IncludeExceptionDetailInFaults vt=\"11\">-1</IncludeExceptionDetailInFaults>" +
                    "<StsUri vt=\"8\">https://biztalk.factory-sb.accesscontrol.windows.net/</StsUri>" +
                    "<IssuerName vt=\"8\">issuer_name</IssuerName>" +
                    "<IssuerSecret vt=\"8\">issuer_secret</IssuerSecret>" +
                    "<EnableServiceDiscovery vt=\"11\">-1</EnableServiceDiscovery>" +
                    "<DiscoveryMode vt=\"8\">Public</DiscoveryMode>" +
                    "<ServiceDisplayName vt=\"8\">display_name</ServiceDisplayName>" +
                    "<OpenTimeout vt=\"8\">00:01:00</OpenTimeout>" +
                    "<SendTimeout vt=\"8\">00:01:00</SendTimeout>" +
                    "<CloseTimeout vt=\"8\">00:01:00</CloseTimeout>" +
                    "<Identity vt=\"8\">" + (
                        "&lt;identity&gt;\r\n  &lt;servicePrincipalName value=\"spn_name\" /&gt;\r\n&lt;/identity&gt;") +
                    "</Identity>" +
                    "</CustomProps>"))
            ;
        }
        public void Validate()
        {
            var wba = new WcfBasicHttpRelayAdapter.Inbound(
                a => {
                a.Address      = new EndpointAddress("https://biztalk.factory.servicebus.windows.net/batch-queue");
                a.TextEncoding = Encoding.ASCII;
            });

            Assert.That(
                () => ((ISupportValidation)wba).Validate(),
                Throws.TypeOf <ArgumentException>()
                .With.InnerException.TypeOf <ArgumentException>()
                .With.InnerException.Message.StartsWith("The text encoding 'us-ascii' used in the text message format is not supported."));
        }
        public void ValidateDoesNotThrow()
        {
            var wba = new WcfBasicHttpRelayAdapter.Inbound(
                a => {
                a.Address                        = new EndpointAddress("https://biztalk.factory.servicebus.windows.net/batch-queue");
                a.Identity                       = EndpointIdentityFactory.CreateSpnIdentity("spn_name");
                a.MaxConcurrentCalls             = 201;
                a.MaxReceivedMessageSize         = 64512;
                a.MessageEncoding                = WSMessageEncoding.Mtom;
                a.SuspendRequestMessageOnFailure = true;
                a.IncludeExceptionDetailInFaults = true;

                a.StsUri       = new Uri("https://biztalk.factory-sb.accesscontrol.windows.net/");
                a.IssuerName   = "issuer_name";
                a.IssuerSecret = "issuer_secret";

                a.EnableServiceDiscovery = true;
                a.ServiceDisplayName     = "display_name";
            });

            Assert.That(() => ((ISupportValidation)wba).Validate(), Throws.Nothing);
        }