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.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 ChangeAssociatedObjectType() { payee1.SetObject(customer1); payee1.ClearObject(); payee1.SetObject(supplier1); Assert.AreEqual(payee1.ContentAsObject, supplier1); key1.AssertValueIsEqual("NakedObjects.SystemTest.ObjectFinderSingleKey.Supplier|1"); }
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 AttemptSetPolymorphicPropertyWithATransientAssociatedObject() { ITestObject transPayment = GetTestService("Polymorphic Payments").GetAction("New Instance").InvokeReturnObject().Save(); ITestObject customer1 = GetTestService("Customer As Payees").GetAction("New Instance").InvokeReturnObject(); string cusId = customer1.GetPropertyByName("Id").Title; ITestProperty payeeProp = transPayment.GetPropertyByName("Payee"); ITestProperty payeeLinkProp = transPayment.GetPropertyByName("Payee Link").AssertIsUnmodifiable().AssertIsEmpty(); try { payeeProp.SetObject(customer1); Assert.Fail("Should not get to here"); } catch (Exception e) { Assert.IsTrue(e.Message.Contains("Can't set field of persistent with a transient reference")); } }
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); }
public virtual void TitleAttributeOnReferencePropertyThatHasATitleMethod() { ITestService rep4 = GetTestService("Object4s"); ITestObject obj4 = rep4.GetAction("New Instance").InvokeReturnObject(); obj4.GetPropertyByName("Prop1").SetValue("Foo"); obj4.AssertTitleEquals("Foo"); obj4.Save(); ITestService rep7 = GetTestService("Object7s"); ITestObject obj7 = rep7.GetAction("New Instance").InvokeReturnObject(); obj7.AssertTitleEquals("Untitled Object7"); prop1 = obj7.GetPropertyByName("Prop1"); prop1.SetObject(obj4); obj7.AssertTitleEquals("Foo"); }
public virtual void TitleAttributeOnReferencePropertyThatHasATitleAttribute() { ITestService rep1 = GetTestService("Object1s"); ITestObject obj1 = rep1.GetAction("New Instance").InvokeReturnObject(); obj1.GetPropertyByName("Prop1").SetValue("Foo"); obj1.AssertTitleEquals("Foo"); obj1.Save(); ITestService rep8 = GetTestService("Object8s"); ITestObject obj8 = rep8.GetAction("New Instance").InvokeReturnObject(); obj8.AssertTitleEquals("Untitled Object8"); prop1 = obj8.GetPropertyByName("Prop1"); prop1.SetObject(obj1); obj8.AssertTitleEquals("Foo"); }
public virtual void TitleAttributeOnReferencePropertyThatHasAToString() { ITestService rep2 = GetTestService("Object2s"); ITestObject obj2 = rep2.GetAction("New Instance").InvokeReturnObject(); obj2.GetPropertyByName("Prop1").SetValue("Foo"); var dom2 = (Object2) obj2.GetDomainObject(); StringAssert.Equals("Foo", dom2.ToString()); obj2.AssertTitleEquals("Foo"); obj2.Save(); ITestService rep9 = GetTestService("Object9s"); ITestObject obj9 = rep9.GetAction("New Instance").InvokeReturnObject(); obj9.AssertTitleEquals("Untitled Object9"); prop1 = obj9.GetPropertyByName("Prop1"); prop1.SetObject(obj2); obj9.AssertTitleEquals("Foo"); }