public CustomerConverter(SetPartnerCustomer setPSCustomer, Customer customer) { mappings = new Dictionary <Func <string>, Action <string> > { { () => setPSCustomer.BillingAddressCity, c => customer.BillingProfile.DefaultAddress.City = c }, { () => setPSCustomer.BillingAddressLine1, c => customer.BillingProfile.DefaultAddress.AddressLine1 = c }, { () => setPSCustomer.BillingAddressLine2, c => customer.BillingProfile.DefaultAddress.AddressLine2 = c }, { () => setPSCustomer.BillingAddressCountry, c => customer.BillingProfile.DefaultAddress.Country = c }, { () => setPSCustomer.BillingAddressPostalCode, c => customer.BillingProfile.DefaultAddress.PostalCode = c }, { () => setPSCustomer.BillingAddressRegion, c => customer.BillingProfile.DefaultAddress.Region = c }, { () => setPSCustomer.BillingAddressState, c => customer.BillingProfile.DefaultAddress.State = c }, { () => setPSCustomer.Name, c => customer.BillingProfile.CompanyName = c } }; }
public void ConvertTest() { Customer customer; SetPartnerCustomer cmdlet; try { cmdlet = new SetPartnerCustomer { BillingAddressLine1 = "12012 Sunset Hills Road", BillingAddressLine2 = "Suite 100", BillingAddressCity = "Reston", BillingAddressCountry = "US", BillingAddressPostalCode = "20190", BillingAddressRegion = "Test-Value", BillingAddressState = "VA", Name = "Microsoft MTC" }; customer = new Customer { BillingProfile = new CustomerBillingProfile { DefaultAddress = new Address { AddressLine1 = "1 Microsoft Way", AddressLine2 = "Second Line", City = "Redmond", Country = "US", PostalCode = "98052", State = "WA" } } }; new CustomerConverter(cmdlet, customer).Convert(); Assert.AreEqual("12012 Sunset Hills Road", customer.BillingProfile.DefaultAddress.AddressLine1); Assert.AreEqual("Suite 100", customer.BillingProfile.DefaultAddress.AddressLine2); Assert.AreEqual("Reston", customer.BillingProfile.DefaultAddress.City); Assert.AreEqual("US", customer.BillingProfile.DefaultAddress.Country); Assert.AreEqual("20190", customer.BillingProfile.DefaultAddress.PostalCode); Assert.AreEqual("Test-Value", customer.BillingProfile.DefaultAddress.Region); Assert.AreEqual("VA", customer.BillingProfile.DefaultAddress.State); Assert.AreEqual("Microsoft MTC", customer.BillingProfile.CompanyName); } finally { cmdlet = null; customer = null; } }