public void Test_SaveBOProp() { //Testing that when a customer is saved the Persisted Property // Value is updated to the PropertyValue //---------------Set up test pack------------------- Customer customer = new Customer(); const string newCustomerName = "Valid Name"; customer.CustomerName = newCustomerName; customer.CustomerCode = "Code"; IBOProp customerNameProp = customer.Props["CustomerName"]; //---------------Assert Precondition---------------- Assert.IsNull(customerNameProp.PersistedPropertyValue, "A new object should not have a persisted value"); Assert.AreEqual(newCustomerName, customerNameProp.Value); Assert.IsTrue(customerNameProp.IsDirty); //---------------Execute Test ---------------------- customer.Save(); //---------------Test Result ----------------------- Assert.AreEqual(newCustomerName, customerNameProp.Value); Assert.AreEqual(newCustomerName, customerNameProp.PersistedPropertyValue, "After saving the PersistedPropertyValue should be backed up to the property value"); Assert.IsFalse(customerNameProp.IsDirty); }
protected static Customer CreateSavedCustomer() { Customer customer = new Customer(); customer.CustomerName = "Valid Name"; customer.CustomerCode = "Code"; customer.Save(); return customer; }
public void Test_SaveValidCustomer() { //---------------Set up test pack------------------- Customer customer = new Customer(); customer.CustomerName = "Valid Name"; customer.CustomerCode = "Code"; //---------------Assert Precondition---------------- Assert.IsTrue(customer.Status.IsNew); Assert.IsTrue(customer.Status.IsDirty); //---------------Execute Test ---------------------- customer.Save(); //---------------Test Result ----------------------- Assert.IsFalse(customer.Status.IsNew); Assert.IsFalse(customer.Status.IsDirty); }
public void Test_Save_Invalid_ValidCustomer() { //---------------Set up test pack------------------- Customer customer = new Customer(); customer.CustomerCode = "Code"; //---------------Assert Precondition---------------- Assert.IsTrue(customer.Status.IsNew); Assert.IsTrue(customer.Status.IsDirty); //---------------Execute Test ---------------------- try { customer.Save(); Assert.Fail("expected Err"); } //---------------Test Result ----------------------- catch (BusObjectInAnInvalidStateException ex) { StringAssert.Contains("'Customer Name' is a compulsory field and has no value", ex.Message); } }