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 virtual void User() { SetUser("Test", sysAdmin); var user = GetTestService("Users").GetAction("Find User By User Name").InvokeReturnObject("Richard").AssertTitleEquals("Richard"); //All properties first ITestProperty prop = null; prop = user.GetPropertyByName("User Name"); AssertIsInvisibleByDefault(prop); AssertIsVisibleByRoles(prop, sysAdmin); AssertIsVisibleByUser(prop, "Richard"); prop = user.GetPropertyByName("Full Name"); AssertIsInvisibleByDefault(prop); AssertIsVisibleByRoles(prop, sysAdmin); AssertIsVisibleByUser(prop, "Richard"); AssertIsModifiableByUser(prop, "Richard"); prop = user.GetPropertyByName("Email Address"); AssertIsInvisibleByDefault(prop); AssertIsVisibleByRoles(prop, sysAdmin); AssertIsVisibleByUser(prop, "Richard"); prop = user.GetPropertyByName("Organisations"); AssertIsInvisibleByDefault(prop); AssertIsVisibleByRoles(prop, sysAdmin); AssertIsVisibleByUser(prop, "Richard"); prop = user.GetPropertyByName("Last Modified"); AssertIsInvisibleByDefault(prop); AssertIsVisibleByRoles(prop, sysAdmin); AssertIsVisibleByUser(prop, "Richard"); }
public void SubClassIsNotPickedUpByTypeAuthorizerWhereSubTypeNameExtendsSupertypeName() { ITestObject fooSub = GetTestService(typeof(SimpleRepository <SubTypeOfFoo>)).GetAction("New Instance").InvokeReturnObject(); ITestProperty prop1 = fooSub.GetPropertyByName("Prop1"); prop1.AssertIsVisible(); prop1.AssertIsModifiable(); }
public void DefaultAuthorizerCalledForNonSpecificType() { ITestObject bar1 = GetTestService(typeof(SimpleRepository <Bar>)).GetAction("New Instance").InvokeReturnObject(); ITestProperty prop1 = bar1.GetPropertyByName("Prop1"); prop1.AssertIsVisible(); prop1.AssertIsModifiable(); }
public virtual void ViewModelRestoresRootGivenKey() { var foo1key = foo1.GetPropertyByName("Id").Title; ITestObject view1 = views.GetAction("New View Foo").InvokeReturnObject(foo1key); ITestProperty root = view1.GetPropertyByName("Root"); root.AssertTitleIsEqual("Foo1"); }
protected void AssertIsModifableByRoles(ITestProperty prop, params string[] roles) { foreach (string role in roles) { SetUser("Test", role); prop.AssertIsModifiable(); } }
public void TearDown() { CleanupNakedObjectsFramework(); countPayments = 0; payment1 = null; customer1 = null; payee1 = null; key1 = null; }
public void CleanUp() { payment1 = null; customer1 = null; payee1 = null; key1 = null; emp1 = null; emp2 = null; }
public virtual void EnumPropertyWithChoicesAndDefault() { ITestObject foo = NewTestObject <Foo>(); ITestProperty sex1 = foo.GetPropertyByName("Sex4").AssertValueIsEqual("Male"); ITestNaked[] values = sex1.GetChoices(); Assert.AreEqual(2, values.Count()); }
public virtual void ObjectWithSimpleToString() { rep = GetTestService("Object2s"); obj = rep.GetAction("New Instance").InvokeReturnObject(); prop1 = obj.GetPropertyByName("Prop1"); prop1.SetValue("Bar"); obj.AssertTitleEquals("Bar"); obj.Save(); obj.AssertTitleEquals("Bar"); }
public virtual TestProp Get(String name) { ITestProperty property = pinternal.Get(name); if (property != null) { return(new TestProp(property)); } return(null); }
public virtual void ObjectWithTitleAttributeOnString() { rep = GetTestService("Object1s"); obj = rep.GetAction("New Instance").InvokeReturnObject(); obj.AssertTitleEquals("Untitled Object1"); prop1 = obj.GetPropertyByName("Prop1"); prop1.SetValue("Foo"); obj.AssertTitleEquals("Foo"); obj.Save(); obj.AssertTitleEquals("Foo"); }
public virtual void TitleMethod() { rep = GetTestService("Object4s"); obj = rep.GetAction("New Instance").InvokeReturnObject(); obj.AssertTitleEquals("Untitled Object4"); prop1 = obj.GetPropertyByName("Prop1"); prop1.SetValue("Foo"); obj.AssertTitleEquals("Foo"); obj.Save(); obj.AssertTitleEquals("Foo"); }
public void Setup() { InitializeNakedObjectsFramework(); payment1 = CreatePayment(); customer1 = CreateCustomer("0c1ced04-7016-11e0-9c44-78544824019b"); customer2 = CreateCustomer("3d9d6ca0-7016-11e0-b12a-9e544824019b"); supplier1 = CreateSupplier("89bc90ec-7017-11e0-a08c-57564824019b"); payee1 = payment1.GetPropertyByName("Payee"); key1 = payment1.GetPropertyByName("Payee Compound Key"); }
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"); }
public virtual void EnumPropertyWithChoices() { ITestObject foo = NewTestObject <Foo>(); ITestProperty sex1 = foo.GetPropertyByName("Sex3").AssertValueIsEqual("Male"); ITestNaked[] values = sex1.GetChoices(); Assert.AreEqual(2, values.Count()); Assert.AreEqual("Male", values.ElementAt(0).NakedObject.TitleString()); Assert.AreEqual("Female", values.ElementAt(1).NakedObject.TitleString()); }
public virtual void UserNameIsCaseInsensitive() { SetUser("Test", sysAdmin); var user = GetTestService("Users").GetAction("Find User By User Name").InvokeReturnObject("Richard").AssertTitleEquals("Richard"); ITestProperty prop = user.GetPropertyByName("User Name"); AssertIsInvisibleByDefault(prop); AssertIsVisibleByUser(prop, "Richard"); AssertIsVisibleByUser(prop, "richard"); }
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 void Setup() { InitializeNakedObjectsFramework(); payment1 = CreatePayment(); customer1 = CreateCustomer(); customer2 = CreateCustomer(); supplier1 = CreateSupplier(); payee1 = payment1.GetPropertyByName("Payee"); key1 = payment1.GetPropertyByName("Payee Compound Key"); emp1 = CreateEmployee("foo"); emp2 = CreateEmployee("bar"); }
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 void Initialize() { InitializeNakedObjectsFramework(); payment1 = CreatePayment(); customer1 = CreateCustomerOnes(); customer2a = CreateCustomerTwos(); customer2b = CreateCustomerTwos(); customer3 = CreateCustomerThrees(); supplier1 = CreateSupplier(); payee1 = payment1.GetPropertyByName("Payee"); key1 = payment1.GetPropertyByName("Payee Compound Key"); emp1 = CreateEmployee("foo"); }
public virtual void VisiblePropertyHasSameNameAsHiddenProperty() { ITestObject obj1 = NewTestObject <Object1>(); try { ITestProperty foo = obj1.GetPropertyByName("Foo"); Assert.Fail("Should not get to here"); } catch (Exception e) { Assert.IsInstanceOfType(e, typeof(AssertFailedException)); Assert.AreEqual("Assert.Fail failed. More than one Property named 'Foo'", e.Message); } }
public void SetUp() { StartTest(); payment1 = GetAllInstances <Payment>(0); payee1 = payment1.GetPropertyByName("Payee"); key1 = payment1.GetPropertyByName("Payee Compound Key"); customer1 = GetAllInstances <Customer>(0); customer2 = GetAllInstances <Customer>(1); supplier1 = GetAllInstances <Supplier>(0); emp1 = GetAllInstances <Employee>(1); emp2 = GetAllInstances <Employee>(0); //They seem to be persisted in reverse order! }
public virtual TestProp this[int index] { get { ITestProperty property = pinternal.GetItem(index); if (property != null) { return(new TestProp(property)); } return(null); } }
public void CleanUp() { EndTest(); payment1 = null; customer1 = null; customer2a = null; customer2b = null; customer3 = null; payee1 = null; key1 = null; emp1 = null; }
public void Initialize() { StartTest(); payment1 = GetAllInstances("Payments", 0); payee1 = payment1.GetPropertyByName("Payee"); key1 = payment1.GetPropertyByName("Payee Compound Key"); customer1 = GetAllInstances("Customers", 0); customer2 = GetAllInstances("Customers", 1); supplier1 = GetAllInstances("Suppliers", 0); emp1 = GetAllInstances("Employees", 1); emp2 = GetAllInstances("Employees", 0); //They seem to be persisted in reverse order! }
public virtual void IntPropertyAsEnum() { ITestObject foo = NewTestObject <Foo>(); ITestProperty sex1 = foo.GetPropertyByName("Sex5"); ITestNaked[] values = sex1.GetChoices(); Assert.AreEqual(4, values.Count()); Assert.AreEqual("Female", values.ElementAt(0).NakedObject.TitleString()); Assert.AreEqual("Male", values.ElementAt(1).NakedObject.TitleString()); Assert.AreEqual("Not Specified", values.ElementAt(2).NakedObject.TitleString()); Assert.AreEqual("Unknown", values.ElementAt(3).NakedObject.TitleString()); }
public virtual Object this[String name] { get { ITestProperty property = this.Get(name); if (property != null) { return(property.Value); } return(null); } set { this.Add(name).Value = value; } }
public void TestInitialize() { InitializeNakedObjectsFrameworkOnce(); StartTest(); payment1 = GetAllInstances <Payment>(0); payee1 = payment1.GetPropertyByName("Payee"); key1 = payment1.GetPropertyByName("Payee Compound Key"); customer1 = GetAllInstances <Customer>(0); customer2 = GetAllInstances <Customer>(1); supplier1 = GetAllInstances <Supplier>(0); emp1 = GetAllInstances <Employee>(1); emp2 = GetAllInstances <Employee>(0); //They seem to be persisted in reverse order! }
public void Initialize() { StartTest(); payment1 = GetAllInstances("Payments", 0); payee1 = payment1.GetPropertyByName("Payee"); key1 = payment1.GetPropertyByName("Payee Compound Key"); customer1 = GetAllInstances("Customer Ones", 0); customer2a = GetAllInstances("Customer Twos", 0); customer2b = GetAllInstances("Customer Twos", 1); customer3 = GetAllInstances("Customer Threes", 0); supplier1 = GetAllInstances("Suppliers", 0); emp1 = GetAllInstances("Employees", 0); }
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 EnumPropertyByteEnum() { ITestObject foo = NewTestObject <Foo>(); ITestProperty sex1 = foo.GetPropertyByName("Hair Colour1"); ITestNaked[] values = sex1.GetChoices(); Assert.AreEqual(5, values.Count()); Assert.AreEqual("Black", values.ElementAt(0).NakedObject.TitleString()); Assert.AreEqual("White", values.ElementAt(4).NakedObject.TitleString()); sex1.AssertFieldEntryIsValid("Brunette"); sex1.AssertFieldEntryInvalid("Fair"); }
public void Initialize() { StartTest(); payment1 = GetTestService("Payments").GetAction("All Instances").InvokeReturnCollection().ElementAt(0); payee1 = payment1.GetPropertyByName("Payee"); key1 = payment1.GetPropertyByName("Payee Compound Key"); var customers = GetTestService("Customers").GetAction("All Instances").InvokeReturnCollection(); customer1 = customers.ElementAt(0); customer2 = customers.ElementAt(1); supplier1 = GetTestService("Suppliers").GetAction("All Instances").InvokeReturnCollection().ElementAt(0); }
public virtual void AuditedEvents() { var sa = GetTestService("Service Actions").GetAction("New Instance").InvokeReturnObject(); ITestProperty prop = null; prop = sa.GetPropertyByName("Service Name"); AssertIsInvisibleByDefault(prop); AssertIsVisibleByRoles(prop, sysAdmin, auditor); prop = sa.GetPropertyByName("Action"); AssertIsInvisibleByDefault(prop); AssertIsVisibleByRoles(prop, sysAdmin, auditor); prop = sa.GetPropertyByName("Parameters"); AssertIsInvisibleByDefault(prop); AssertIsVisibleByRoles(prop, sysAdmin, auditor); prop = sa.GetPropertyByName("Date Time"); AssertIsInvisibleByDefault(prop); AssertIsVisibleByRoles(prop, sysAdmin, auditor); prop = sa.GetPropertyByName("User Name"); AssertIsInvisibleByDefault(prop); AssertIsVisibleByRoles(prop, sysAdmin, auditor); var oa = GetTestService("Object Actions").GetAction("New Instance").InvokeReturnObject(); prop = oa.GetPropertyByName("Object"); AssertIsInvisibleByDefault(prop); AssertIsVisibleByRoles(prop, sysAdmin, auditor); prop = oa.GetPropertyByName("Action"); AssertIsInvisibleByDefault(prop); AssertIsVisibleByRoles(prop, sysAdmin, auditor); prop = oa.GetPropertyByName("Parameters"); AssertIsInvisibleByDefault(prop); AssertIsVisibleByRoles(prop, sysAdmin, auditor); var ou = GetTestService("Object Updateds").GetAction("New Instance").InvokeReturnObject(); prop = ou.GetPropertyByName("Object"); AssertIsInvisibleByDefault(prop); AssertIsVisibleByRoles(prop, sysAdmin, auditor); prop = ou.GetPropertyByName("Snapshot"); AssertIsInvisibleByDefault(prop); AssertIsVisibleByRoles(prop, sysAdmin, auditor); }
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 void CleanUp() { CleanupNakedObjectsFramework(); countPayments = 0; countCustomerTwos = 0; countSuppliers = 0; countEmployees = 0; payment1 = null; customer1 = null; customer2a = null; customer2b = null; customer3 = null; payee1 = null; key1 = null; emp1 = null; }
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 String this[String name] { get { ITestProperty property = pinternal.Get(name); if (property != null) { return(StringEx.ToString(property.Value)); } return(null); } set { this.Add(name).Value = value; } }
public virtual void EnumPropertyBasic() { ITestObject foo = NewTestObject <Foo>(); ITestProperty sex1 = foo.GetPropertyByName("Sex1"); ITestNaked[] values = sex1.GetChoices(); Assert.AreEqual(4, values.Count()); Assert.AreEqual("Female", values.ElementAt(0).NakedObject.TitleString()); Assert.AreEqual("Male", values.ElementAt(1).NakedObject.TitleString()); Assert.AreEqual("Not Specified", values.ElementAt(2).NakedObject.TitleString()); Assert.AreEqual("Unknown", values.ElementAt(3).NakedObject.TitleString()); sex1.AssertFieldEntryIsValid("Male"); sex1.AssertFieldEntryInvalid("Man"); }
public void Initialize() { StartTest(); payment1 = GetAllInstances(typeof(SimpleRepository <Payment>), 0); payee1 = payment1.GetPropertyByName("Payee"); key1 = payment1.GetPropertyByName("Payee Compound Key"); customer1 = GetAllInstances(typeof(SimpleRepository <CustomerOne>), 0); customer2a = GetAllInstances(typeof(SimpleRepository <CustomerTwo>), 0); customer2b = GetAllInstances(typeof(SimpleRepository <CustomerTwo>), 1); customer3 = GetAllInstances(typeof(SimpleRepository <CustomerThree>), 0); customer4 = GetAllInstances(typeof(SimpleRepository <CustomerFour>), 0); customer4a = GetAllInstances(typeof(SimpleRepository <CustomerFour>), 1); supplier1 = GetAllInstances(typeof(SimpleRepository <Supplier>), 0); emp1 = GetAllInstances(typeof(SimpleRepository <Employee>), 0); }
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 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 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 void Initialize() { InitializeNakedObjectsFramework(); foo1 = GetTestService("Foos").GetAction("New Instance").InvokeReturnObject(); prop1 = foo1.GetPropertyByName("Prop1"); act1 = foo1.GetAction("Act1"); }
public virtual void TitleAttributeTakesPrecedenceOverTitleMethod() { rep = GetTestService("Object6s"); obj = rep.GetAction("New Instance").InvokeReturnObject(); var dom = (Object6) obj.GetDomainObject(); StringAssert.Equals("Bar", dom.ToString()); StringAssert.Equals("Hex", dom.Title()); obj.AssertTitleEquals("Untitled Object6"); prop1 = obj.GetPropertyByName("Prop1"); prop1.SetValue("Foo"); obj.AssertTitleEquals("Foo"); obj.Save(); obj.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"); }
public void Cleanup() { CleanupNakedObjectsFramework(); foo1 = null; prop1 = null; act1 = null; }
//Constructor public TestProp(ITestProperty property) { pinternal = property; }
private static void CheckForClearTests(ITestProperty prop0, ITestProperty prop1) { prop1.AssertIsEmpty(); prop0.AssertValueIsEqual("Prop1 has been cleared"); }