public void UpdateCustomer_WithValidation_Test() { var customer = new TestCustomer() { Name = "Test Customer" }; _client.Create(customer); Assert.IsNotNull(customer.RecId); Assert.AreEqual("[From Handler] Test Customer", customer.Name); customer.Phone = "7854454544"; try { _client.Update(customer); } catch { //update phone and keep going customer.Phone = "785-445-4544"; } _client.Update(customer); var customerQuery = _client.GetQuery<TestCustomer>().ForRecId(customer.RecId); var sameCustomer = _client.ExecuteQuery(customerQuery); Assert.AreEqual("785-445-4544", sameCustomer.First().Phone); _client.Delete(customer); }
public void CreateCustomer_Test() { var customer = new TestCustomer() { Name = _testCustomerName }; _client.Create(customer); Assert.IsNotNull(customer.RecId); Assert.AreEqual("[From Handler] Test Customer", customer.Name); }
public void CreateCustomer_CreateTransactionFails_CustomerIsDeleted() { // This will trip the field validation and cause the transaction to fail const string customerName = "Fail Transaction Name"; var customer = new TestCustomer { Name = customerName }; try { _client.Create(customer); } catch { // Swallow the exception to let us assert the rollback worked } var readFromCherwell = _client.ExecuteQuery(_client.GetQuery<TestCustomer>().Where(x => x.Name == customerName)).FirstOrDefault(); Assert.IsNull(readFromCherwell); }