public virtual void ChangePolymorphicPropertyOnPersistentObject(string customerType, string supplierType) { var payment2 = FindById <PolymorphicPayment>(3); var customer1 = FindById <CustomerAsPayee>(1); string cusId = customer1.GetPropertyByName("Id").Title; ITestProperty payeeProp = payment2.GetPropertyByName("Payee"); ITestProperty payeeLinkProp = payment2.GetPropertyByName("Payee Link").AssertIsUnmodifiable(); payeeProp.SetObject(customer1); ITestObject payeeLink = payeeLinkProp.AssertIsNotEmpty().ContentAsObject; ITestProperty associatedType = payeeLink.GetPropertyByName("Associated Role Object Type").AssertIsUnmodifiable(); associatedType.AssertValueIsEqual(customerType); ITestProperty associatedId = payeeLink.GetPropertyByName("Associated Role Object Id").AssertIsUnmodifiable(); associatedId.AssertValueIsEqual(cusId); ITestObject sup1 = GetTestService("Supplier As Payees").GetAction("New Instance").InvokeReturnObject().Save(); string supId = sup1.GetPropertyByName("Id").Title; payeeProp.SetObject(sup1); associatedType.AssertValueIsEqual(supplierType); associatedId.AssertValueIsEqual(supId); payeeProp.ClearObject(); payeeLinkProp.AssertIsEmpty(); payeeProp.AssertIsEmpty(); }
public void ChangeAssociatedObjectType() { payee1.SetObject(customer1); payee1.ClearObject(); payee1.SetObject(supplier1); Assert.AreEqual(payee1.ContentAsObject, supplier1); key1.AssertValueIsEqual("NakedObjects.SystemTest.ObjectFinderSingleKey.Supplier|1"); }
public void ChangeAssociatedObjectType() { payee1.SetObject(customer1); payee1.ClearObject(); payee1.SetObject(supplier1); Assert.AreEqual(payee1.ContentAsObject, supplier1); key1.AssertValueIsEqual("NakedObjects.SystemTest.ObjectFinderGuid.Supplier|89bc90ec-7017-11e0-a08c-57564824019b"); }
public void SetAssociatedObject() { payee1.SetObject(customer1); key1.AssertValueIsEqual("NakedObjects.SystemTest.ObjectFinderGuid.Customer|0c1ced04-7016-11e0-9c44-78544824019b"); payee1.SetObject(customer2); Assert.AreEqual(payee1.ContentAsObject, customer2); key1.AssertValueIsEqual("NakedObjects.SystemTest.ObjectFinderGuid.Customer|3d9d6ca0-7016-11e0-b12a-9e544824019b"); }
public void SetAssociatedObject() { payee1.SetObject(customer1); key1.AssertValueIsEqual("NakedObjects.SystemTest.ObjectFinderSingleKey.Customer|1"); payee1.SetObject(customer2); Assert.AreEqual(payee1.ContentAsObject, customer2); key1.AssertValueIsEqual("NakedObjects.SystemTest.ObjectFinderSingleKey.Customer|2"); }
public virtual void ExceptionInUpdatedCausesWholeTransactionToFail() { ITestAction qs = GetTestService(typeof(SimpleRepository <Qux1>)).GetAction("All Instances"); ITestObject q = qs.InvokeReturnCollection().AssertCountIs(1).ElementAt(0); ITestProperty name = q.GetPropertyByName("Name"); name.AssertValueIsEqual("Qux 1"); try { triggerFail = true; name.SetValue("yyy"); } catch { triggerFail = false; q.Refresh(); q = qs.InvokeReturnCollection().AssertCountIs(1).ElementAt(0); name = q.GetPropertyByName("Name"); name.AssertValueIsEqual("Qux 1"); } }
public virtual void CMaskOnDecimalProperty() { obj = NewTestObject<Object2>(); prop1 = obj.GetPropertyByName("Prop1"); prop1.SetValue("32.70"); var dom = (Object2) obj.GetDomainObject(); StringAssert.Equals("32.7", dom.Prop1.ToString()); StringAssert.Equals("32.70", prop1.Content.Title); StringAssert.Equals("£32.70", prop1.Title); prop1.AssertTitleIsEqual("£32.70"); prop1.AssertValueIsEqual("32.70"); }
public virtual void TestPropertyValue() { ITestObject obj = NewTestObject <Object1>(); obj.GetPropertyById("Prop3").SetValue("16/08/2013"); ITestProperty p1 = obj.GetPropertyById("Prop3"); p1.AssertValueIsEqual("16/08/2013 00:00:00"); p1.AssertTitleIsEqual("16/08/2013"); }
private void SetupForClearTests(out ITestProperty prop0, out ITestProperty prop1) { ITestObject obj = NewTestObject<Object1>(); prop0 = obj.GetPropertyByName("Prop0"); prop1 = obj.GetPropertyByName("Prop1"); prop0.AssertIsEmpty(); prop1.AssertIsEmpty(); prop1.SetValue("Foo"); prop1.AssertValueIsEqual("Foo"); prop0.AssertIsEmpty(); }
public virtual void IdIsSetByTheTimePersistedIsCalled() { ITestObject foo = GetTestService(typeof(SimpleRepository <Foo1>)).GetAction("New Instance").InvokeReturnObject(); foo.AssertIsTransient(); ITestProperty id = foo.GetPropertyByName("Id").AssertValueIsEqual("0"); ITestProperty idPersisting = foo.GetPropertyByName("Id On Persisting").AssertValueIsEqual("0"); ITestProperty idPersisted = foo.GetPropertyByName("Id On Persisted").AssertValueIsEqual("0"); foo.Save().AssertIsPersistent(); id.AssertValueIsEqual("1"); idPersisting.AssertValueIsEqual("0"); idPersisted.AssertValueIsEqual("1"); }
public virtual void DMaskOnDateProperty() { obj = NewTestObject<Object1>(); prop1 = obj.GetPropertyByName("Prop1"); prop1.SetValue("23/09/2009 11:34:50"); prop2 = obj.GetPropertyByName("Prop2"); prop2.SetValue("23/09/2009 11:34:50"); var dom = (Object1) obj.GetDomainObject(); StringAssert.Equals("23/09/2009 11:34:50", dom.Prop1.ToString()); StringAssert.Equals("23/09/2009 11:34:50", prop1.Content.Title); StringAssert.Equals("23/09/2009 11:34:50", dom.Prop2.ToString()); StringAssert.Equals("23/09/2009", prop2.Content.Title); prop1.AssertTitleIsEqual("23/09/2009 11:34:50"); prop1.AssertValueIsEqual("23/09/2009 11:34:50"); prop2.AssertTitleIsEqual("23/09/2009"); prop2.AssertValueIsEqual("23/09/2009 11:34:50"); }
public virtual void TestPropertyValue() { var culture = Thread.CurrentThread.CurrentCulture; try { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; ITestObject obj = NewTestObject <Object1>(); obj.GetPropertyById("Prop3").SetValue("08/16/2013"); ITestProperty p1 = obj.GetPropertyById("Prop3"); p1.AssertValueIsEqual("08/16/2013 00:00:00"); p1.AssertTitleIsEqual("08/16/2013"); } finally { Thread.CurrentThread.CurrentCulture = culture; } }
public virtual void SetPolymorphicPropertyOnPersistentObject(string roleObjectType) { var payment1 = FindById <PolymorphicPayment>(1); var customer1 = FindById <CustomerAsPayee>(1); string cusId = customer1.GetPropertyByName("Id").Title; ITestProperty payeeProp = payment1.GetPropertyByName("Payee").AssertIsEmpty(); ITestProperty payeeLinkProp = payment1.GetPropertyByName("Payee Link").AssertIsUnmodifiable().AssertIsEmpty(); payeeProp.SetObject(customer1); ITestObject payeeLink = payment1.GetPropertyByName("Payee Link").AssertIsNotEmpty().ContentAsObject; ITestProperty associatedType = payeeLink.GetPropertyByName("Associated Role Object Type").AssertIsUnmodifiable(); associatedType.AssertValueIsEqual(roleObjectType); ITestProperty associatedId = payeeLink.GetPropertyByName("Associated Role Object Id").AssertIsUnmodifiable(); associatedId.AssertValueIsEqual(cusId); }
public virtual void SetPolymorphicPropertyOnTransientObject(string roleObjectType) { ITestObject transPayment = GetTestService("Polymorphic Payments").GetAction("New Instance").InvokeReturnObject(); ITestObject customer1 = GetTestService("Customer As Payees").GetAction("New Instance").InvokeReturnObject().Save(); string cusId = customer1.GetPropertyByName("Id").Title; ITestProperty payeeProp = transPayment.GetPropertyByName("Payee"); ITestProperty payeeLinkProp = transPayment.GetPropertyByName("Payee Link").AssertIsUnmodifiable().AssertIsEmpty(); payeeProp.SetObject(customer1); transPayment.Save(); ITestObject payeeLink = payeeLinkProp.AssertIsNotEmpty().ContentAsObject; ITestProperty associatedType = payeeLink.GetPropertyByName("Associated Role Object Type").AssertIsUnmodifiable(); associatedType.AssertValueIsEqual(roleObjectType); ITestProperty associatedId = payeeLink.GetPropertyByName("Associated Role Object Id").AssertIsUnmodifiable(); associatedId.AssertValueIsEqual(cusId); }
private static void CheckForClearTests(ITestProperty prop0, ITestProperty prop1) { prop1.AssertIsEmpty(); prop0.AssertValueIsEqual("Prop1 has been cleared"); }