public void TestMap() { var guid = Guid.NewGuid(); var model = new EntityModel { Fields = new List <Field> { new Field { Name = "tc_sourcesystemid", Type = FieldType.Guid, Value = guid }, new Field { Name = Attributes.Customer.Salutation, Type = FieldType.String, Value = "salutation" }, new Field { Name = Attributes.Customer.FirstName, Type = FieldType.String, Value = "firstname" }, new Field { Name = Attributes.Customer.LastName, Type = FieldType.String, Value = "lastname" }, new Field { Name = Attributes.Customer.Language, Type = FieldType.String, Value = "language" }, new Field { Name = Attributes.Customer.Birthdate, Type = FieldType.DateTime, Value = DateTime.Now.Date } } }; var mapper = new CreateCustomerRequestMapper(); var customer = mapper.Map(model) as Customer; Assert.IsNotNull(customer); Assert.IsNotNull(customer.CustomerIdentifier); Assert.AreEqual(guid.ToString(), customer.CustomerIdentifier.CustomerId); Assert.IsNotNull(customer.CustomerIdentity); Assert.AreEqual("salutation", customer.CustomerIdentity.Salutation); Assert.AreEqual("firstname", customer.CustomerIdentity.FirstName); Assert.AreEqual("lastname", customer.CustomerIdentity.LastName); Assert.AreEqual("language", customer.CustomerIdentity.Language); Assert.AreEqual(DateTime.Now.Date.ToShortDateString(), customer.CustomerIdentity.Birthdate); }
public void TestCreateMap() { var model = new EntityModel { Fields = new List <Field> { new Field { Name = Attributes.Customer.SourceMarket, Type = FieldType.String, Value = "sourcemarket" }, new Field { Name = Attributes.Customer.StatusCode, Type = FieldType.OptionSet, Value = new OptionSet { Value = 1 } }, new Field { Name = Attributes.Customer.Salutation, Type = FieldType.String, Value = "salutation" }, new Field { Name = Attributes.Customer.AcademicTitle, Type = FieldType.String, Value = "academictitle" }, new Field { Name = Attributes.Customer.FirstName, Type = FieldType.String, Value = "firstname" }, new Field { Name = Attributes.Customer.LastName, Type = FieldType.String, Value = "lastname" }, new Field { Name = Attributes.Customer.MiddleName, Type = FieldType.String, Value = "middlename" }, new Field { Name = Attributes.Customer.Language, Type = FieldType.String, Value = "language" }, new Field { Name = Attributes.Customer.Gender, Type = FieldType.OptionSet, Value = new OptionSet { Value = 950000000 } }, new Field { Name = Attributes.Customer.Birthdate, Type = FieldType.DateTime, Value = DateTime.Now.Date }, new Field { Name = Attributes.Customer.Name, Type = FieldType.String, Value = "customername" }, new Field { Name = Attributes.Customer.Segment, Type = FieldType.String, Value = "segment" }, new Field { Name = Attributes.Customer.DateOfDeath, Type = FieldType.DateTime, Value = DateTime.Now.Date }, new Field { Name = Attributes.Customer.Address1AdditionaInformation, Type = FieldType.String, Value = "addressadditionalanformation1" }, new Field { Name = Attributes.Customer.Address1FlatOrUnitNumber, Type = FieldType.String, Value = "addressflatnumberunit1" }, new Field { Name = Attributes.Customer.Address1HouseNumberOrBuilding, Type = FieldType.String, Value = "addresshousenumberbuilding1" }, new Field { Name = Attributes.Customer.Address1Street, Type = FieldType.String, Value = "addressstreet1" }, new Field { Name = Attributes.Customer.Address1Town, Type = FieldType.String, Value = "addresstown1" }, new Field { Name = Attributes.Customer.Address1CountryId, Type = FieldType.String, Value = "addresscountry1" }, new Field { Name = Attributes.Customer.Address1County, Type = FieldType.String, Value = "addresscounty1" }, new Field { Name = Attributes.Customer.Address1PostalCode, Type = FieldType.String, Value = "addresspostalcode1" }, new Field { Name = Attributes.Customer.Address2AdditionaInformation, Type = FieldType.String, Value = "addressadditionalanformation2" }, new Field { Name = Attributes.Customer.Address2FlatOrUnitNumber, Type = FieldType.String, Value = "addressflatnumberunit2" }, new Field { Name = Attributes.Customer.Address2HouseNumberOrBuilding, Type = FieldType.String, Value = "addresshousenumberbuilding2" }, new Field { Name = Attributes.Customer.Address2Street, Type = FieldType.String, Value = "addressstreet2" }, new Field { Name = Attributes.Customer.Address2Town, Type = FieldType.String, Value = "addresstown2" }, new Field { Name = Attributes.Customer.Address2CountryId, Type = FieldType.String, Value = "addresscountry2" }, new Field { Name = Attributes.Customer.Address2County, Type = FieldType.String, Value = "addresscounty2" }, new Field { Name = Attributes.Customer.Address2PostalCode, Type = FieldType.String, Value = "addresspostalcode2" }, new Field { Name = Attributes.Customer.Telephone1Type, Type = FieldType.OptionSet, Value = new OptionSet { Value = 950000000 } }, new Field { Name = Attributes.Customer.Telephone1, Type = FieldType.String, Value = "telephonenumber1" }, new Field { Name = Attributes.Customer.Telephone2Type, Type = FieldType.OptionSet, Value = new OptionSet { Value = 950000003 } }, new Field { Name = Attributes.Customer.Telephone2, Type = FieldType.String, Value = "telephonenumber2" }, new Field { Name = Attributes.Customer.Telephone3Type, Type = FieldType.OptionSet, Value = new OptionSet { Value = 950000002 } }, new Field { Name = Attributes.Customer.Telephone3, Type = FieldType.String, Value = "telephonenumber3" }, new Field { Name = Attributes.Customer.EmailAddress1Type, Type = FieldType.OptionSet, Value = new OptionSet { Value = 950000000 } }, new Field { Name = Attributes.Customer.EmailAddress1, Type = FieldType.String, Value = "emailaddress1" }, new Field { Name = Attributes.Customer.EmailAddress2Type, Type = FieldType.OptionSet, Value = new OptionSet { Value = 950000001 } }, new Field { Name = Attributes.Customer.EmailAddress2, Type = FieldType.String, Value = "emailaddress2" }, new Field { Name = Attributes.Customer.EmailAddress3Type, Type = FieldType.OptionSet, Value = new OptionSet { Value = 950000002 } }, new Field { Name = Attributes.Customer.EmailAddress3, Type = FieldType.String, Value = "emailaddress3" } } }; var mapper = new CreateCustomerRequestMapper(); var customer = mapper.Map(model) as Customer; Assert.IsNotNull(customer); Assert.IsNotNull(customer.CustomerIdentity); Assert.AreEqual("sourcemarket", customer.CustomerIdentifier.SourceMarket); Assert.AreEqual(CustomerStatus.Active, customer.CustomerGeneral.CustomerStatus); Assert.AreEqual("salutation", customer.CustomerIdentity.Salutation); Assert.AreEqual("academictitle", customer.CustomerIdentity.AcademicTitle); Assert.AreEqual("firstname", customer.CustomerIdentity.FirstName); Assert.AreEqual("lastname", customer.CustomerIdentity.LastName); Assert.AreEqual("middlename", customer.CustomerIdentity.MiddleName); Assert.AreEqual("language", customer.CustomerIdentity.Language); Assert.AreEqual(Gender.Male, customer.CustomerIdentity.Gender); Assert.AreEqual(DateTime.Now.Date.ToShortDateString(), customer.CustomerIdentity.Birthdate); Assert.AreEqual("customername", customer.Company.CompanyName); Assert.AreEqual("segment", customer.Additional.Segment); Assert.AreEqual(DateTime.Now.Date.ToShortDateString(), customer.Additional.DateOfDeath); Assert.AreEqual("addressadditionalanformation1", customer.Address[0].AdditionalAddressInfo); Assert.AreEqual("addressflatnumberunit1", customer.Address[0].FlatNumberUnit); Assert.AreEqual("addresshousenumberbuilding1", customer.Address[0].HouseNumberBuilding); Assert.AreEqual("addressstreet1", customer.Address[0].Street); Assert.AreEqual("addresstown1", customer.Address[0].Town); Assert.AreEqual("addresscountry1", customer.Address[0].Country); Assert.AreEqual("addresscounty1", customer.Address[0].County); Assert.AreEqual("addresspostalcode1", customer.Address[0].PostalCode); Assert.AreEqual("addressadditionalanformation2", customer.Address[1].AdditionalAddressInfo); Assert.AreEqual("addressflatnumberunit2", customer.Address[1].FlatNumberUnit); Assert.AreEqual("addresshousenumberbuilding2", customer.Address[1].HouseNumberBuilding); Assert.AreEqual("addressstreet2", customer.Address[1].Street); Assert.AreEqual("addresstown2", customer.Address[1].Town); Assert.AreEqual("addresscountry2", customer.Address[1].Country); Assert.AreEqual("addresscounty2", customer.Address[1].County); Assert.AreEqual("addresspostalcode2", customer.Address[1].PostalCode); Assert.AreEqual(PhoneType.Mobile, customer.Phone[0].PhoneType); Assert.AreEqual("telephonenumber1", customer.Phone[0].Number); Assert.AreEqual(PhoneType.Business, customer.Phone[1].PhoneType); Assert.AreEqual("telephonenumber2", customer.Phone[1].Number); Assert.AreEqual(PhoneType.NotSpecified, customer.Phone[2].PhoneType); Assert.AreEqual("telephonenumber3", customer.Phone[2].Number); Assert.AreEqual(EmailType.Primary, customer.Email[0].EmailType); Assert.AreEqual("emailaddress1", customer.Email[0].Address); Assert.AreEqual(EmailType.Promo, customer.Email[1].EmailType); Assert.AreEqual("emailaddress2", customer.Email[1].Address); Assert.AreEqual(EmailType.NotSpecified, customer.Email[2].EmailType); Assert.AreEqual("emailaddress3", customer.Email[2].Address); }