示例#1
0
 /// <summary>
 /// Generate Address Object with meaningful CountryCode, ZipCode and State
 /// </summary>
 /// <param name="state"></param>
 /// <param name="zip"></param>
 /// <param name="country"></param>
 /// <returns></returns>
 public static Mozu.Api.Contracts.Core.Address GenerateAddress(string state, string zip, bool realAddress = false, string country = "US")
 {
     var address = new Mozu.Api.Contracts.Core.Address
     {
         CountryCode = country,
         PostalOrZipCode = zip,
         StateOrProvince = state,
         IsValidated = true
     };
     if (realAddress)
     {
         if (state.ToUpper().Equals("TX") && zip.Equals("78717"))
         {
             address.Address1 = "9900 W. Parmer Lane";
             address.CityOrTown = "Austin";
         }
         else if (state.ToUpper().Equals("NY") && zip.Equals("11238"))
         {
             address.Address1 = "950 Fulton St";
             address.CityOrTown = "Brooklyn";
         }
         else if (state.ToUpper().Equals("NC") && zip.Equals("27601"))
         {
             address.Address1 = "91 E Edenton St";
             address.CityOrTown = "Raleigh";
         }
         else if (state.ToUpper().Equals("CA") && zip.Equals("95814"))
         {
             address.Address1 = "State Capital, Suite 1173";
             address.CityOrTown = "Sacramento";
         }
         else
         {
             throw (new TestInconclusiveException(0, System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(CultureInfo.InvariantCulture),
                null, "No real address found."));
         }
     }
     else
     {
         return new Mozu.Api.Contracts.Core.Address()
         {
             Address1 =
                 string.Format("{0} {1}",
                               Generator.RandomString(8, Generator.RandomCharacterGroup.NumericOnly),
                               Generator.RandomString(75, Generator.RandomCharacterGroup.AlphaNumericOnly)),
             Address2 = Generator.RandomString(50, Generator.RandomCharacterGroup.AlphaNumericOnly),
             Address3 = Generator.RandomString(20, Generator.RandomCharacterGroup.AlphaNumericOnly),
             Address4 = Generator.RandomString(15, Generator.RandomCharacterGroup.AlphaNumericOnly),
             CityOrTown = Generator.RandomString(25, Generator.RandomCharacterGroup.AlphaOnly),
             CountryCode = country,
             PostalOrZipCode = zip,
             StateOrProvince = state
         };
     }
     return address;
 }
示例#2
0
 public static Mozu.Api.Contracts.Core.Address GenerateInternationalAddress(string country)
 {
     var address = new Mozu.Api.Contracts.Core.Address();
     address.CountryCode = country;
     address.IsValidated = true;
     switch (country)
     {
         case "CA":
             address.Address1 = "1 Sussex Drive";
             address.CityOrTown = "Ottawa";
             address.PostalOrZipCode = "K1A 0A1";
             address.StateOrProvince = "Ontario";
             break;
         case "GB":
             address.Address1 = "HARTMANNSTRASSE 7";
             address.CityOrTown = "BONN";
             address.PostalOrZipCode = "53001";
             address.StateOrProvince = "";
             break;
         case "TW":
             address.Address1 = "3F #12 LN 410 SEC 2 PA-TEH RD";
             address.CityOrTown = "TAIPEI";
             address.PostalOrZipCode = "105";
             address.StateOrProvince = "";
             break;
     }
     return (address);
 }