Author: gbayon
Date: Sat Oct 21 03:21:35 2006
New Revision: 466369
URL: http://svn.apache.org/viewvc?view=rev&rev=466369
Log:
Add unit test to setter/getter access to public generic property and private
generic variable
Modified:
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Property.cs
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs
Modified: ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Property.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Property.cs?view=diff&rev=466369&r1=466368&r2=466369
==============================================================================
--- ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Property.cs (original)
+++ ibatis/trunk/cs/mapper/IBatisNet.Common.Test/Domain/Property.cs Sat Oct 21
03:21:35 2006
@@ -253,5 +253,29 @@
get { return _float; }
set { _float = value*2; }
}
+
+#if dotnet2
+ private SpecialReference<Account> _referenceAccount = null;
+ public SpecialReference<Account> ReferenceAccount
+ {
+ get { return _referenceAccount; }
+ set { _referenceAccount = value; }
+ }
+#endif
+
}
+
+#if dotnet2
+ public class SpecialReference<T> where T : class
+ {
+ private T _value =null;
+
+ public T Value
+ {
+ get { return _value; }
+ set { _value = value; }
+ }
+ }
+#endif
+
}
Modified:
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs
URL:
http://svn.apache.org/viewvc/ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs?view=diff&rev=466369&r1=466368&r2=466369
==============================================================================
---
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs
(original)
+++
ibatis/trunk/cs/mapper/IBatisNet.Common.Test/NUnit/CommonTests/Utilities/PropertyAccessorTest.cs
Sat Oct 21 03:21:35 2006
@@ -233,6 +233,78 @@
Assert.AreEqual(-99 * 2, accessorGet.Get(son));
}
+
+ /// <summary>
+ /// Test getter access to Public Generic Property
+ /// </summary>
+ [Test]
+ 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);
+ }
+
+ /// <summary>
+ /// Test setter access to Public Generic Property
+ /// </summary>
+ [Test]
+ 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);
+ }
+
+ /// <summary>
+ /// Test getter access to private Generic Property
+ /// </summary>
+ [Test]
+ public void TestPrivateGetterOnGenericProperty()
+ {
+ 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);
+ }
+
+ /// <summary>
+ /// Test setter access to Public Generic Property
+ /// </summary>
+ [Test]
+ public void TestPrivateSetterOnGenericVariable()
+ {
+ 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);
+ }
}
}