public void TestSetAccount() { Property prop = new Property(); prop.Account = new Account() ; prop.Account.FirstName = "test"; // Property accessor string firstName = "Gilles"; Account test = new Account(); test.FirstName = firstName; accountSetAccessor.Set(prop, test); Assert.AreEqual(firstName, prop.Account.FirstName); }
public void SetPublicAccount(Property p, Account ac) { p.publicAccount = ac; }
public void TestGetAccount() { Account test = new Account(); test.FirstName = "Gilles"; Property prop = new Property(); prop.Account = test; // Property accessor Assert.AreEqual(HashCodeProvider.GetIdentityHashCode(test), HashCodeProvider.GetIdentityHashCode(prop.Account)); Assert.AreEqual(test.FirstName, ((Account)accountGetAccessor.Get(prop)).FirstName); }
public void TestSetNullOnAccountField() { Property prop = new Property(); Account ac = new Account(); ac.FirstName = "test"; FieldInfo fieldInfo = GetFieldInfo("protectedAccount"); fieldInfo.SetValue(prop, ac); // Property accessor accountSetAccessor.Set(prop, null); Assert.AreEqual(null, fieldInfo.GetValue(prop)); }
public void TestGetAccountField() { Account test = new Account(); test.FirstName = "Gilles"; Property prop = new Property(); FieldInfo fieldInfo = GetFieldInfo("protectedAccount"); fieldInfo.SetValue(prop, test); // Property accessor Assert.AreEqual(HashCodeProvider.GetIdentityHashCode(test), HashCodeProvider.GetIdentityHashCode(fieldInfo.GetValue(prop))); Assert.AreEqual(test.FirstName, ((Account)accountGetAccessor.Get(prop)).FirstName); }
public void TestSetAccountField() { Property prop = new Property(); Account ac = new Account(); ac.FirstName = "test"; FieldInfo fieldInfo = GetFieldInfo("protectedAccount"); fieldInfo.SetValue(prop, ac); // Property accessor string firstName = "Gilles"; Account test = new Account(); test.FirstName = firstName; accountSetAccessor.Set(prop, test); Assert.AreEqual(firstName, ((Account)fieldInfo.GetValue(prop) ).FirstName); }
public void TestPublicSetterOnGenericVariable2() { ISetAccessor accessorSet = factorySet.CreateSetAccessor(typeof(SpecialReference<Account>), "Value"); SpecialReference<Account> referenceAccount = new SpecialReference<Account>(); Account account = new Account(5); accessorSet.Set(referenceAccount, account); Assert.AreEqual(account, referenceAccount.Value); Assert.AreEqual(account.Id, referenceAccount.Value.Id); }
public void TestPublicSetterOnGenericVariable() { ISetAccessor accessorSet = factorySet.CreateSetAccessor(typeof(PropertySon), "ReferenceAccount"); PropertySon son = new PropertySon(); SpecialReference<Account> referenceAccount = new SpecialReference<Account>(); Account account = new Account(5); referenceAccount.Value = account; accessorSet.Set(son, referenceAccount); Assert.AreEqual(son.ReferenceAccount, referenceAccount); Assert.AreEqual(son.ReferenceAccount.Value.Id, referenceAccount.Value.Id); }
public void TestPublicGetterOnGenericProperty2() { IGetAccessor accessorGet = factoryGet.CreateGetAccessor(typeof(SpecialReference<Account>), "Value"); SpecialReference<Account> referenceAccount = new SpecialReference<Account>(); Account account = new Account(5); referenceAccount.Value = account; Account acc = accessorGet.Get(referenceAccount) as Account; Assert.AreEqual(referenceAccount.Value, acc); Assert.AreEqual(referenceAccount.Value.Id, acc.Id); }
public void TestPublicGetterOnGenericProperty() { IGetAccessor accessorGet = factoryGet.CreateGetAccessor(typeof(PropertySon), "ReferenceAccount"); PropertySon son = new PropertySon(); son.ReferenceAccount = new SpecialReference<Account>(); Account account = new Account(5); son.ReferenceAccount.Value = account; SpecialReference<Account> acc = accessorGet.Get(son) as SpecialReference<Account>; Assert.AreEqual(account, acc.Value); Assert.AreEqual(account.Id, acc.Value.Id); }