Exemplo n.º 1
0
        public void CanSerialize()
        {
            var contact = new DomainContact
            {
                FirstName        = "John",
                LastName         = "Doe",
                OrganizationName = "Tucows",
                Address1         = "141 Lafayette St.",
                Address2         = "Floor 99",
                City             = "New York",
                State            = "NY",
                Country          = "US",
                PostalCode       = "10013",
                Email            = "*****@*****.**",
                Phone            = "+1.8661111111"
            };

            var request = new RegisterRequest
            {
                Domain   = "test.com",
                Contacts = new ContactSet
                {
                    Admin   = contact,
                    Billing = contact,
                    Tech    = contact,
                    Owner   = contact
                },
                AutoRenew        = false,
                LockDomain       = true,
                RegistrationType = RegistrationType.New,
                Period           = 1,
                WhoisPrivacy     = true,
                UserName         = "******",
                Password         = "******"
            };

            var text = request.ToXml().ToString();

            Assert.Equal(
                @"<OPS_envelope>
  <header>
    <version>0.9</version>
  </header>
  <body>
    <data_block>
      <dt_assoc>
        <item key=""protocol"">XCP</item>
        <item key=""action"">SW_REGISTER</item>
        <item key=""object"">DOMAIN</item>
        <item key=""attributes"">
          <dt_assoc>
            <item key=""auto_renew"">0</item>
            <item key=""contact_set"">
              <dt_assoc>
                <item key=""owner"">
                  <dt_assoc>
                    <item key=""first_name"">John</item>
                    <item key=""last_name"">Doe</item>
                    <item key=""phone"">+1.8661111111</item>
                    <item key=""email"">[email protected]</item>
                    <item key=""org_name"">Tucows</item>
                    <item key=""address1"">141 Lafayette St.</item>
                    <item key=""address2"">Floor 99</item>
                    <item key=""city"">New York</item>
                    <item key=""state"">NY</item>
                    <item key=""country"">US</item>
                    <item key=""postal_code"">10013</item>
                  </dt_assoc>
                </item>
                <item key=""admin"">
                  <dt_assoc>
                    <item key=""first_name"">John</item>
                    <item key=""last_name"">Doe</item>
                    <item key=""phone"">+1.8661111111</item>
                    <item key=""email"">[email protected]</item>
                    <item key=""org_name"">Tucows</item>
                    <item key=""address1"">141 Lafayette St.</item>
                    <item key=""address2"">Floor 99</item>
                    <item key=""city"">New York</item>
                    <item key=""state"">NY</item>
                    <item key=""country"">US</item>
                    <item key=""postal_code"">10013</item>
                  </dt_assoc>
                </item>
                <item key=""tech"">
                  <dt_assoc>
                    <item key=""first_name"">John</item>
                    <item key=""last_name"">Doe</item>
                    <item key=""phone"">+1.8661111111</item>
                    <item key=""email"">[email protected]</item>
                    <item key=""org_name"">Tucows</item>
                    <item key=""address1"">141 Lafayette St.</item>
                    <item key=""address2"">Floor 99</item>
                    <item key=""city"">New York</item>
                    <item key=""state"">NY</item>
                    <item key=""country"">US</item>
                    <item key=""postal_code"">10013</item>
                  </dt_assoc>
                </item>
                <item key=""billing"">
                  <dt_assoc>
                    <item key=""first_name"">John</item>
                    <item key=""last_name"">Doe</item>
                    <item key=""phone"">+1.8661111111</item>
                    <item key=""email"">[email protected]</item>
                    <item key=""org_name"">Tucows</item>
                    <item key=""address1"">141 Lafayette St.</item>
                    <item key=""address2"">Floor 99</item>
                    <item key=""city"">New York</item>
                    <item key=""state"">NY</item>
                    <item key=""country"">US</item>
                    <item key=""postal_code"">10013</item>
                  </dt_assoc>
                </item>
              </dt_assoc>
            </item>
            <item key=""custom_nameservers"">0</item>
            <item key=""custom_tech_contact"">0</item>
            <item key=""f_lock_domain"">1</item>
            <item key=""domain"">test.com</item>
            <item key=""handle"">process</item>
            <item key=""period"">1</item>
            <item key=""reg_username"">test</item>
            <item key=""reg_password"">password</item>
            <item key=""reg_type"">new</item>
            <item key=""f_whois_privacy"">1</item>
          </dt_assoc>
        </item>
      </dt_assoc>
    </data_block>
  </body>
</OPS_envelope>", text);
        }