public void ExistingEventCampaign() { // //Test Parameters // string altCustId = ConfigurationManager.AppSettings["AltCustId"]; string eventName = ConfigurationManager.AppSettings["EventName"]; string tokenName = ConfigurationManager.AppSettings["TokenName"]; string tokenValue = ConfigurationManager.AppSettings["TokenValue"]; // BrickStreetConnect brickst = makeClient(); HttpStatusCode status; string statusMessage; string timecode = DateTime.Now.ToLongTimeString(); Customer customer = brickst.GetCustomerByAltId(altCustId, out status, out statusMessage); if (customer == null) { string randomEmail = "user" + timecode + "@example.com"; customer = new Customer(); customer.EmailAddress = randomEmail; customer.AltCustomerId = altCustId; Customer cust2 = brickst.AddCustomer(customer, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); throw new Exception("null customer received from add customer"); } } long custId = Convert.ToInt32(customer.Id); if (!string.IsNullOrEmpty(tokenName) && !string.IsNullOrEmpty(tokenValue)) { //fetch attribute metadata BrickStAPI.Connect.Attribute attrDef = brickst.GetCustomerAttribute(tokenName, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); } string attrType = attrDef.Type; bool doupdate = false; CustomerAttribute attr = customer.GetChannelAddress(tokenName); if (string.Compare("attribute", attrType, StringComparison.OrdinalIgnoreCase) == 0) { if (attr == null) { attr = new CustomerAttribute(); attr.Name = attrDef.Name; attr.Type = attrDef.Type; attr.DataType = attrDef.DataType; attr.Value = tokenValue; customer.Attributes.Add(attr); doupdate = true; } else { // update if new if (!tokenValue.Equals(attr.Value)) { attr.Value = tokenValue; doupdate = true; } } } else if (string.Compare("preference", attrType, StringComparison.OrdinalIgnoreCase) == 0) { if (attr == null) { attr = new CustomerAttribute(); attr.Name = attrDef.Name; attr.Type = attrDef.Type; attr.DataType = attrDef.DataType; // start with 1 value attr.PreferenceValues = new String[1]; attr.PreferenceValues[0] = tokenValue; customer.ChannelAddresses.Add(attr); doupdate = true; } else { // existing preference record // add the token value if it is not already there // the push channel code will automatically remove invalid device tokens String[] vals = attr.PreferenceValues; bool valuefound = false; for (int i = 0; i < vals.Length; i++) { String val = vals[i]; if (tokenValue.Equals(val)) { valuefound = true; break; } } if (!valuefound) { String[] newVals = new String[vals.Length + 1]; Array.Copy(vals, 0, newVals, 0, vals.Length); newVals[newVals.Length - 1] = tokenValue; attr.PreferenceValues = newVals; doupdate = true; } } } // save updated customer record if necessary if (doupdate) { Customer custSave2 = brickst.UpdateCustomer(customer, out status, out statusMessage); if (custSave2 == null) { throw new Exception("null customer received from updateCustomer"); } customer = custSave2; } } // //create an event record // BrickStreetAPI.Connect.Event eventObj = new BrickStreetAPI.Connect.Event(); eventObj.EventName = eventName; eventObj.CustomerId = custId; eventObj.Subscribe = true; eventObj.Parameters = new List <EventParameter>(); DateTime now = new DateTime(); //event parameter: Message EventParameter ep1 = new EventParameter(); ep1.ParameterName = "Message"; ep1.ParameterValue = "Test at " + now.ToString(); ep1.Encrypted = false; eventObj.Parameters.Add(ep1); //event parameter:Badge EventParameter ep2 = new EventParameter(); ep2.ParameterName = "Badge"; ep2.ParameterValue = "42"; ep2.Encrypted = false; eventObj.Parameters.Add(ep2); //event parameter: AlertID EventParameter ep3 = new EventParameter(); ep3.ParameterName = "AlertID"; ep3.ParameterValue = timecode; ep3.Encrypted = false; eventObj.Parameters.Add(ep3); // //submit event to connect // BrickStreetAPI.Connect.Event posted = brickst.AddEvent(eventObj, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); throw new Exception("addEvent returned null"); } long eventQueueId = Convert.ToInt32(posted.Id); long eventId = Convert.ToInt32(posted.EventId); Console.WriteLine("Posted Event;ID=" + eventQueueId + " for CustomerID=" + custId + " and Event ID=" + eventId); }
public void AddCustomerWithMultiaddress() { string preferenceName = ConfigurationManager.AppSettings["MultiaddressName"]; HttpStatusCode status; string statusMessage; BrickStreetConnect brickStreetConnect = makeClient(); BrickStAPI.Connect.Attribute attrDef = brickStreetConnect.GetCustomerAttribute(preferenceName, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); } Assert.IsNotNull(attrDef); string attrType = attrDef.Type; //create new customer Random r = new Random(); long val = r.Next(); if (val < 0) { val *= -1; } String custVal = "cmaeda+" + val + "@cmaeda.com"; Customer c = new Customer(); c.EmailAddress = custVal; c.AltCustomerId = custVal; c.AddressLine1 = "215 S Broadway 241"; c.City = "Salem"; c.State = "NH"; c.Country = "USA"; Customer c2 = brickStreetConnect.AddCustomer(c, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); } Assert.IsNotNull(c2, "Customer is null"); Assert.IsNotNull(c2.Id, "Customer ID is null"); Assert.AreEqual(c2.EmailAddress, custVal); Assert.AreEqual(c2.AltCustomerId, custVal); c = c2; // //add preference // CustomerAttribute attr = null; if (string.Compare("preference", attrType, StringComparison.OrdinalIgnoreCase) == 0) { attr = c.GetAttribute(preferenceName); if (attr == null) { attr = new CustomerAttribute(); attr.Name = attrDef.Name; attr.Type = attrDef.Type; attr.DataType = attrDef.DataType; //start with 1 value attr.PreferenceValues = new string[1]; attr.PreferenceValues[0] = "pval" + val; c.Attributes.Add(attr); } else { string[] vals = attr.PreferenceValues; string[] newVals = new string[vals.Length + 1]; Array.Copy(vals, 0, newVals, 0, vals.Length); newVals[newVals.Length - 1] = "pval" + val; attr.PreferenceValues = newVals; } } else if (string.Compare("multiaddress", attrType, StringComparison.OrdinalIgnoreCase) == 0) { //add a channel address attr = c.GetChannelAddress(preferenceName); if (attr == null) { attr = new CustomerAttribute(); attr.Name = attrDef.Name; attr.Type = attrDef.Type; attr.DataType = attrDef.DataType; //start with 1 value attr.PreferenceValues = new string[1]; attr.PreferenceValues[0] = "pval" + val; c.ChannelAddresses.Add(attr); } else { string[] vals = attr.PreferenceValues; string[] newVals = new string[vals.Length + 1]; Array.Copy(vals, 0, newVals, 0, vals.Length); newVals[newVals.Length - 1] = "pval" + val; attr.PreferenceValues = newVals; } } else { Assert.IsTrue(false, "Unknown pref type " + attrType); } //save orig value string[] prefVals = attr.PreferenceValues; c2 = brickStreetConnect.UpdateCustomer(c, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); } Assert.IsNotNull(c2, "Customer 2 is null"); //check saved data CustomerAttribute c2attr = null; if (string.Compare("preference", attrType, StringComparison.OrdinalIgnoreCase) == 0) { c2attr = c2.GetAttribute(preferenceName); } else if (string.Compare("multiaddress", attrType, StringComparison.OrdinalIgnoreCase) == 0) { c2attr = c2.GetChannelAddress(preferenceName); } Assert.IsNotNull(c2attr); CollectionAssert.AreEquivalent(prefVals, c2attr.PreferenceValues); c = c2; // //add a second pref value // //new random value val = r.Next(); if (val < 0) { val *= -1; } if (string.Compare("preference", attrType, StringComparison.OrdinalIgnoreCase) == 0) { attr = c.GetAttribute(preferenceName); Assert.IsNotNull(attr); //add a value string[] vals = attr.PreferenceValues; string[] newVals = new string[vals.Length + 1]; Array.Copy(vals, 0, newVals, 0, vals.Length); newVals[newVals.Length - 1] = "pval" + val; attr.PreferenceValues = newVals; } else if (string.Compare("multiaddress", attrType, StringComparison.OrdinalIgnoreCase) == 0) { //add a channel attr = c.GetChannelAddress(preferenceName); Assert.IsNotNull(attr); string[] vals = attr.PreferenceValues; string[] newVals = new string[vals.Length + 1]; Array.Copy(vals, 0, newVals, 0, vals.Length); newVals[newVals.Length - 1] = "pval" + val; attr.PreferenceValues = newVals; } else { Assert.IsTrue(false, "Unknown pref type " + attrType); } prefVals = attr.PreferenceValues; c2 = brickStreetConnect.UpdateCustomer(c, out status, out statusMessage); Assert.IsNotNull(c2, "Customer 2 is null"); //check saved data c2attr = null; if (string.Compare("preference", attrType, StringComparison.OrdinalIgnoreCase) == 0) { c2attr = c2.GetAttribute(preferenceName); } else if (string.Compare("multiaddress", attrType, StringComparison.OrdinalIgnoreCase) == 0) { c2attr = c2.GetChannelAddress(preferenceName); } Assert.IsNotNull(c2attr); CollectionAssert.AreEquivalent(prefVals, c2attr.PreferenceValues); c = c2; // //remove a preference // if (string.Compare("preference", attrType, StringComparison.OrdinalIgnoreCase) == 0) { attr = c2.GetAttribute(preferenceName); } else if (string.Compare("multiaddress", attrType, StringComparison.OrdinalIgnoreCase) == 0) { attr = c2.GetChannelAddress(preferenceName); } Assert.IsNotNull(attr); //remove first value string[] oldVals = attr.PreferenceValues; string[] newVals1 = new string[oldVals.Length - 1]; Array.Copy(oldVals, 1, newVals1, 0, newVals1.Length); attr.PreferenceValues = newVals1; prefVals = attr.PreferenceValues; c2 = brickStreetConnect.UpdateCustomer(c, out status, out statusMessage); Assert.AreNotEqual(c2, "Customer 2 is null"); //check saved data c2attr = null; if (string.Compare("preference", attrType, StringComparison.OrdinalIgnoreCase) == 0) { c2attr = c2.GetAttribute(preferenceName); } else if (string.Compare("multiaddress", attrType, StringComparison.OrdinalIgnoreCase) == 0) { c2attr = c2.GetChannelAddress(preferenceName); } Assert.IsNotNull(c2attr); CollectionAssert.AreEquivalent(prefVals, c2attr.PreferenceValues); }
public void CustomerApiTest() { string altCustId = "TEST" + DateTime.Now.Ticks.ToString(); string email = altCustId + "@example.com"; Customer cust = new Customer { AltCustomerId = altCustId, StatusCode = 1, EmailAddress = email, FirstName = "Test", LastName = "Testman" }; HttpStatusCode status; string statusMessage; BrickStreetConnect brickStreetConnect = makeClient(); // // create new customer record // Customer dbCust = brickStreetConnect.AddCustomer(cust, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); } Assert.AreEqual(HttpStatusCode.OK, status); Assert.IsNull(statusMessage); Assert.IsNotNull(dbCust); Assert.IsNotNull(dbCust.Id); Assert.AreEqual(cust.AltCustomerId, dbCust.AltCustomerId); Assert.AreEqual(cust.EmailAddress, dbCust.EmailAddress); Assert.AreEqual(cust.LastName, dbCust.LastName); Assert.AreEqual(cust.FirstName, dbCust.FirstName); // // now try the get methods on the new customer // Customer getCust = brickStreetConnect.GetCustomer((long)dbCust.Id, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); } Assert.AreEqual(HttpStatusCode.OK, status); Assert.IsNull(statusMessage); Assert.IsNotNull(getCust); Assert.IsNotNull(getCust.Id); Assert.AreEqual(dbCust.AltCustomerId, getCust.AltCustomerId); Assert.AreEqual(dbCust.EmailAddress, getCust.EmailAddress); Assert.AreEqual(dbCust.LastName, getCust.LastName); Assert.AreEqual(dbCust.FirstName, getCust.FirstName); getCust = brickStreetConnect.GetCustomerByAltId(altCustId, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); } Assert.AreEqual(HttpStatusCode.OK, status); Assert.IsNull(statusMessage); Assert.IsNotNull(getCust); Assert.IsNotNull(getCust.Id); Assert.AreEqual(dbCust.AltCustomerId, getCust.AltCustomerId); Assert.AreEqual(dbCust.EmailAddress, getCust.EmailAddress); Assert.AreEqual(dbCust.LastName, getCust.LastName); Assert.AreEqual(dbCust.FirstName, getCust.FirstName); getCust = brickStreetConnect.GetCustomerByEmail(email, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); } Assert.AreEqual(HttpStatusCode.OK, status); Assert.IsNull(statusMessage); Assert.IsNotNull(getCust); Assert.IsNotNull(getCust.Id); Assert.AreEqual(dbCust.AltCustomerId, getCust.AltCustomerId); Assert.AreEqual(dbCust.EmailAddress, getCust.EmailAddress); Assert.AreEqual(dbCust.LastName, getCust.LastName); Assert.AreEqual(dbCust.FirstName, getCust.FirstName); // // update the customer // getCust.FirstName = "Testy"; getCust.LastName = "Testyman"; getCust.AddressLine1 = "123 Oak St"; getCust.City = "Oakland"; getCust.State = "CA"; dbCust = brickStreetConnect.UpdateCustomer(getCust, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); } Assert.AreEqual(HttpStatusCode.OK, status); Assert.IsNull(statusMessage); Assert.IsNotNull(dbCust); Assert.IsNotNull(dbCust.Id); Assert.AreEqual((long)getCust.Id, (long)dbCust.Id); Assert.AreEqual(getCust.AltCustomerId, dbCust.AltCustomerId); Assert.AreEqual(getCust.EmailAddress, dbCust.EmailAddress); Assert.AreEqual(getCust.LastName, dbCust.LastName); Assert.AreEqual(getCust.FirstName, dbCust.FirstName); Assert.AreEqual(getCust.AddressLine1, dbCust.AddressLine1); Assert.AreEqual(getCust.City, dbCust.City); Assert.AreEqual(getCust.State, dbCust.State); // // dbCust is valid; recheck GET methods // getCust = brickStreetConnect.GetCustomer((long)dbCust.Id, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); } Assert.AreEqual(HttpStatusCode.OK, status); Assert.IsNull(statusMessage); Assert.IsNotNull(getCust); Assert.IsNotNull(getCust.Id); Assert.AreEqual(dbCust.AltCustomerId, getCust.AltCustomerId); Assert.AreEqual(dbCust.EmailAddress, getCust.EmailAddress); Assert.AreEqual(dbCust.LastName, getCust.LastName); Assert.AreEqual(dbCust.FirstName, getCust.FirstName); getCust = brickStreetConnect.GetCustomerByAltId(altCustId, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); } Assert.AreEqual(HttpStatusCode.OK, status); Assert.IsNull(statusMessage); Assert.IsNotNull(getCust); Assert.IsNotNull(getCust.Id); Assert.AreEqual(dbCust.AltCustomerId, getCust.AltCustomerId); Assert.AreEqual(dbCust.EmailAddress, getCust.EmailAddress); Assert.AreEqual(dbCust.LastName, getCust.LastName); Assert.AreEqual(dbCust.FirstName, getCust.FirstName); getCust = brickStreetConnect.GetCustomerByEmail(email, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); } Assert.AreEqual(HttpStatusCode.OK, status); Assert.IsNull(statusMessage); Assert.IsNotNull(getCust); Assert.IsNotNull(getCust.Id); Assert.AreEqual(dbCust.AltCustomerId, getCust.AltCustomerId); Assert.AreEqual(dbCust.EmailAddress, getCust.EmailAddress); Assert.AreEqual(dbCust.LastName, getCust.LastName); Assert.AreEqual(dbCust.FirstName, getCust.FirstName); }
public void AddCustomerWithAttribute() { String attributeName = ConfigurationManager.AppSettings["AttrName"];//this will be probably fetched from app.config String attributeValue = ConfigurationManager.AppSettings["AttrValue"]; HttpStatusCode status; string statusMessage; BrickStreetConnect brickStreetConnect = makeClient(); var attrDef = brickStreetConnect.GetCustomerAttribute(attributeName, out status, out statusMessage); Assert.AreNotEqual(attrDef, "Attribute Not Found"); //create new customer Random r = new Random(); long val = r.Next(); if (val < 0) { val *= -1; } String custVal = "cmaeda" + val + "@cmaeda.com"; Customer c = new Customer(); c.EmailAddress = custVal; c.AltCustomerId = custVal; c.AddressLine1 = "215 S Broadway 241"; c.City = "Salem"; c.State = "NH"; c.Country = "USA"; Customer c2 = brickStreetConnect.AddCustomer(c, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); } Assert.IsNotNull(c2); Assert.IsNotNull(c2.Id); Assert.AreEqual(c2.EmailAddress, custVal); Assert.AreEqual(c2.AltCustomerId, custVal); CustomerAttribute attr = c2.GetAttribute(attributeName); if (attr == null) { attr = new CustomerAttribute(); attr.Name = attrDef.Name; attr.Type = attrDef.Type; attr.DataType = attrDef.DataType; attr.Value = attributeValue; c2.Attributes.Add(attr); } else { attr.Value = attributeValue; } Customer c3 = brickStreetConnect.UpdateCustomer(c2, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); } Assert.IsNotNull(c3, "Customer 3 is null"); CustomerAttribute c3attr = c3.GetAttribute(attributeName); Assert.IsNotNull(c3attr); Assert.AreEqual(c3attr.Value, attributeValue); }
public void EventReceiptTest() { BrickStreetConnect brickst = makeClient(); HttpStatusCode status; string statusMessage = null; // // verify that conversation exists // // CONV NAME: "TEST ERECEIPT CONVERSATION" // // SPENTLY: SHOULD CREATE A CONVERSATION OBJECT FOR EACH SPENTLY ACCOUNT Conversation conv = brickst.GetConversationByName("TEST ERECEIPT CONVERSATION", out status, out statusMessage); if (status == HttpStatusCode.NotFound) { // conversation not found; create it Assert.IsNull(conv, "Expected null conversation"); conv = new Conversation(); conv.Name = "TEST ERECEIPT CONVERSATION"; conv.DepartmentID = ConnectDepartmentID; Conversation conv2 = brickst.AddConversation(conv, out status, out statusMessage); Assert.AreEqual(HttpStatusCode.OK, status); Assert.IsNotNull(conv2); Assert.IsNotNull(conv2.Id); Assert.AreEqual(conv.Name, conv2.Name); conv = conv2; } Assert.IsNotNull(conv); // // create new campaign // string campaignName = "TEST ERECEIPT " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); EventMaster eventMaster = new EventMaster() { Name = campaignName, IncludeXML = true }; // NO EVENT PARAMS EventCampaign camp = new EventCampaign() { Name = campaignName, Type = Campaign.EVENT_CAMPAIGN, ConversationID = conv.Id, DepartmentID = ConnectDepartmentID, Event = eventMaster }; EventCampaign savedCamp = brickst.AddEventCampaign(camp, out status, out statusMessage); Assert.AreEqual(HttpStatusCode.OK, status); Assert.IsNotNull(savedCamp); Assert.IsNotNull(savedCamp.Id); Assert.AreEqual(ConnectDepartmentID, savedCamp.DepartmentID); camp = savedCamp; // // create content // CampaignContent cont = new CampaignContent() { Name = campaignName + " CONTENT", Type = CampaignContent.TYPE_XSL, Subject = "TEST SUBJ LINE FOR " + campaignName, // // NOTE: THIS URL SHOULD BE THE URL OF THE RECEIPT TEMPLATE XSL !!! /// HtmlContentURL = "http://content.brickst.net/eNotify/spently/eReceipt/spently-receipt2.xsl", CampaignID = (long)camp.Id }; CampaignContent cont2 = brickst.AddCampaignContent(cont, out status, out statusMessage); if (statusMessage != null) { Console.WriteLine("ERROR SAVING CONTENT: " + statusMessage); } Assert.AreEqual(HttpStatusCode.OK, status); Assert.IsNotNull(cont2); Assert.IsNotNull(cont2.Id); cont = cont2; // // create message interaction to use the content // CampaignInteraction inter = new CampaignInteraction() { Name = "Test Interaction 1", Type = CampaignInteraction.TYPE_MAIN_MESSAGE, CampaignID = (long)camp.Id, ContentID = (long)cont.Id, SegmentID = 1 }; CampaignInteraction inter2 = brickst.AddMessage(inter, out status, out statusMessage); Assert.AreEqual(HttpStatusCode.OK, status); Assert.IsNotNull(inter2); Assert.IsNotNull(inter2.Id); inter = inter2; // // Prepare to Launch the Interaction // RolloutAction raction = new RolloutAction() { Action = RolloutAction.ACTION_PREPARE_LAUNCH, EffectiveDate = DateTime.Now.ToUniversalTime() }; RolloutActionResponse raresp = brickst.DoRolloutAction((long)camp.Id, (long)inter.Id, raction, out status, out statusMessage); if (statusMessage != null) { Console.WriteLine("ERROR ROLLOUT ACTION 1: " + statusMessage); } Assert.AreEqual(HttpStatusCode.OK, status); Assert.IsNotNull(raresp); Assert.AreEqual(RolloutActionResponse.STATUS_OK, raresp.Status); raction = new RolloutAction() { Action = RolloutAction.ACTION_LAUNCH }; raresp = brickst.DoRolloutAction((long)camp.Id, (long)inter.Id, raction, out status, out statusMessage); if (statusMessage != null) { Console.WriteLine("ERROR ROLLOUT ACTION 2: " + statusMessage); } Assert.AreEqual(HttpStatusCode.OK, status); Assert.IsNotNull(raresp); Assert.AreEqual(RolloutActionResponse.STATUS_OK, raresp.Status); // // event campaign is active; create a customer and submit events // string altCustId = "TEST" + DateTime.Now.Ticks.ToString(); string email = altCustId + "@cmaeda.com"; Customer cust = new Customer { AltCustomerId = altCustId, StatusCode = 1, EmailAddress = email, FirstName = "Test", LastName = "Testman" }; Customer dbCust = brickst.AddCustomer(cust, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); } Assert.AreEqual(HttpStatusCode.OK, status); Assert.IsNull(statusMessage); Assert.IsNotNull(dbCust); Assert.IsNotNull(dbCust.Id); Assert.AreEqual(cust.AltCustomerId, dbCust.AltCustomerId); Assert.AreEqual(cust.EmailAddress, dbCust.EmailAddress); Assert.AreEqual(cust.LastName, dbCust.LastName); Assert.AreEqual(cust.FirstName, dbCust.FirstName); cust = dbCust; // // have customer, submit event // StringBuilder bld = new StringBuilder(); bld.Append("<purchase>"); bld.Append("<customer_name>"); bld.Append(cust.FirstName).Append(" ").Append(cust.LastName); bld.Append("</customer_name>"); bld.Append("<line_items>"); // LINE ITEM... bld.Append("<item>"); bld.Append("<item_name>Hat</item_name>"); bld.Append("<item_quantity>1</item_quantity>"); bld.Append("<item_price>9.95</item_price>"); bld.Append("</item>"); // LINE ITEM... bld.Append("<item>"); bld.Append("<item_name>Shoes</item_name>"); bld.Append("<item_quantity>1</item_quantity>"); bld.Append("<item_price>19.95</item_price>"); bld.Append("</item>"); bld.Append("</line_items>"); bld.Append("</purchase>"); string xml = bld.ToString(); Event tstEvent = new Event { EventName = campaignName, CustomerId = (long)cust.Id, Xml = xml, Subscribe = true }; Event dbEvent = brickst.AddEvent(tstEvent, out status, out statusMessage); if (status != HttpStatusCode.OK) { Console.WriteLine("ERROR: STATUS:" + status.ToString() + " " + statusMessage); } Assert.AreEqual(HttpStatusCode.OK, status); Assert.IsNull(statusMessage); Assert.IsNotNull(dbEvent); Assert.IsNotNull(dbEvent.Id); Assert.AreEqual(tstEvent.EventName, dbEvent.EventName); Assert.AreEqual(tstEvent.CustomerId, dbEvent.CustomerId); Assert.AreEqual("1", dbEvent.Status); Console.WriteLine("SUBMITTED EVENT " + dbEvent.Id); }