From: Michael D. <mik...@us...> - 2004-08-23 13:13:37
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/PropertyTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16606/NHibernate.Test/PropertyTest Modified Files: CamelCaseFixture.cs CamelCaseUnderscoreFixture.cs FieldAccessorFixture.cs FieldClass.cs PascalCaseMUnderscoreFixture.cs Added Files: NoSetterAccessorFixture.cs NoSetterCamelCaseFixture.cs NoSetterCamelCaseUnderscoreFixture.cs NoSetterPascalCaseMUnderscoreFixture.cs Log Message: Added test for access="nosetter" --- NEW FILE: NoSetterCamelCaseFixture.cs --- using System; using NHibernate.Property; using NUnit.Framework; namespace NHibernate.Test.PropertyTest { /// <summary> /// Summary description for NoSetterCamelCaseFixture. /// </summary> [TestFixture] public class NoSetterCamelCaseFixture : NoSetterAccessorFixture { [SetUp] public override void SetUp() { _expectedCamelBazGetterCalled = true; _accessor = PropertyAccessorFactory.GetPropertyAccessor("nosetter.camelcase"); _getter = _accessor.GetGetter( typeof(FieldClass), "CamelBaz" ); _setter = _accessor.GetSetter( typeof(FieldClass), "CamelBaz" ); _instance = new FieldClass( 6, -1, 2, 0 ); } } } --- NEW FILE: NoSetterCamelCaseUnderscoreFixture.cs --- using System; using NHibernate.Property; using NUnit.Framework; namespace NHibernate.Test.PropertyTest { /// <summary> /// Summary description for NoSetterCamelCaseUnderscoreFixture. /// </summary> [TestFixture] public class NoSetterCamelCaseUnderscoreFixture : NoSetterAccessorFixture { [SetUp] public override void SetUp() { _expectedCamelUnderscoreFooGetterCalled = true; _accessor = PropertyAccessorFactory.GetPropertyAccessor("nosetter.camelcase-underscore"); _getter = _accessor.GetGetter( typeof(FieldClass), "CamelUnderscoreFoo" ); _setter = _accessor.GetSetter( typeof(FieldClass), "CamelUnderscoreFoo" ); _instance = new FieldClass( 6, 0, -1, 2 ); } } } --- NEW FILE: NoSetterPascalCaseMUnderscoreFixture.cs --- using System; using NHibernate.Property; using NUnit.Framework; namespace NHibernate.Test.PropertyTest { /// <summary> /// Summary description for NoSetterCamelCaseUnderscoreFixture. /// </summary> [TestFixture] public class NoSetterPascalCaseMUnderscoreFixture : NoSetterAccessorFixture { [SetUp] public override void SetUp() { _expectedBlahGetterCalled = true; _accessor = PropertyAccessorFactory.GetPropertyAccessor("nosetter.pascalcase-m-underscore"); _getter = _accessor.GetGetter( typeof(FieldClass), "Blah" ); _setter = _accessor.GetSetter( typeof(FieldClass), "Blah" ); _instance = new FieldClass( 6, -1, 0, 2 ); } } } Index: CamelCaseFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/PropertyTest/CamelCaseFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CamelCaseFixture.cs 23 Aug 2004 02:10:31 -0000 1.1 --- CamelCaseFixture.cs 23 Aug 2004 13:13:25 -0000 1.2 *************** *** 17,22 **** { _accessor = PropertyAccessorFactory.GetPropertyAccessor("field.camelcase"); ! _getter = _accessor.GetGetter( typeof(FieldClass), "Id" ); ! _setter = _accessor.GetSetter( typeof(FieldClass), "Id" ); _instance = new FieldClass(2, -4, 3, 0 ); } --- 17,22 ---- { _accessor = PropertyAccessorFactory.GetPropertyAccessor("field.camelcase"); ! _getter = _accessor.GetGetter( typeof(FieldClass), "CamelBaz" ); ! _setter = _accessor.GetSetter( typeof(FieldClass), "CamelBaz" ); _instance = new FieldClass(2, -4, 3, 0 ); } Index: FieldClass.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/PropertyTest/FieldClass.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FieldClass.cs 23 Aug 2004 02:10:31 -0000 1.2 --- FieldClass.cs 23 Aug 2004 13:13:25 -0000 1.3 *************** *** 9,22 **** { private int Id; ! private int _id; ! private int m_Id; ! private int id; ! public FieldClass(int Id, int underscoreId, int mUnderscoreId, int camelId ) { this.Id = Id; ! _id = underscoreId; ! m_Id = mUnderscoreId; ! id = camelId; } --- 9,26 ---- { private int Id; ! private int _camelUnderscoreFoo; ! private int m_Blah; ! private int camelBaz; ! public bool CamelUnderscoreFooGetterCalled = false; ! public bool BlahGetterCalled = false; ! public bool CamelBazGetterCalled = false; ! ! public FieldClass(int Id, int _camelUnderscoreFoo, int m_Blah, int camelBaz ) { this.Id = Id; ! this._camelUnderscoreFoo = _camelUnderscoreFoo; ! this.m_Blah = m_Blah; ! this.camelBaz = camelBaz; } *************** *** 24,30 **** { Id++; ! _id++; ! m_Id++; ! id++; } } --- 28,61 ---- { Id++; ! _camelUnderscoreFoo++; ! m_Blah++; ! camelBaz++; ! } ! ! public int CamelUnderscoreFoo ! { ! get ! { ! CamelUnderscoreFooGetterCalled = true; ! return _camelUnderscoreFoo; ! } ! } ! ! public int Blah ! { ! get ! { ! BlahGetterCalled = true; ! return m_Blah; ! } ! } ! ! public int CamelBaz ! { ! get ! { ! CamelBazGetterCalled = true; ! return camelBaz; ! } } } --- NEW FILE: NoSetterAccessorFixture.cs --- using System; using NHibernate.Property; using NUnit.Framework; namespace NHibernate.Test.PropertyTest { /// <summary> /// Base test fixture for the NoSetter Accessors. /// </summary> [TestFixture] public abstract class NoSetterAccessorFixture { protected IPropertyAccessor _accessor; protected IGetter _getter; protected ISetter _setter; protected FieldClass _instance; protected bool _expectedBlahGetterCalled = false; protected bool _expectedCamelBazGetterCalled = false; protected bool _expectedCamelUnderscoreFooGetterCalled = false; /// <summary> /// SetUp the local fields for the test cases. /// </summary> /// <remarks> /// Any classes testing out their field access should override this /// and setup their FieldClass instance so that whichever field is /// going to be reflected upon is initialized to 0. /// </remarks> [SetUp] public abstract void SetUp(); [Test] public void GetValue() { Assert.AreEqual( 0, _getter.Get(_instance) ); _instance.Increment(); Assert.AreEqual( 1, _getter.Get(_instance) ); Assert.AreEqual( _expectedBlahGetterCalled, _instance.BlahGetterCalled ); Assert.AreEqual( _expectedCamelBazGetterCalled, _instance.CamelBazGetterCalled ); Assert.AreEqual( _expectedCamelUnderscoreFooGetterCalled, _instance.CamelUnderscoreFooGetterCalled ); } [Test] public void SetValue() { Assert.AreEqual( 0, _getter.Get(_instance) ); _setter.Set( _instance, 5 ); Assert.AreEqual( 5, _getter.Get(_instance) ); } } } Index: FieldAccessorFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/PropertyTest/FieldAccessorFixture.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FieldAccessorFixture.cs 23 Aug 2004 02:10:31 -0000 1.2 --- FieldAccessorFixture.cs 23 Aug 2004 13:13:25 -0000 1.3 *************** *** 32,36 **** _getter = _accessor.GetGetter( typeof(FieldClass), "Id" ); _setter = _accessor.GetSetter( typeof(FieldClass), "Id" ); ! _instance = new FieldClass( 0, 6, -1, 2); } --- 32,36 ---- _getter = _accessor.GetGetter( typeof(FieldClass), "Id" ); _setter = _accessor.GetSetter( typeof(FieldClass), "Id" ); ! _instance = new FieldClass( 0, 6, -1, 2 ); } *************** *** 42,45 **** --- 42,49 ---- _instance.Increment(); Assert.AreEqual( 1, _getter.Get(_instance) ); + + Assert.IsFalse( _instance.BlahGetterCalled ); + Assert.IsFalse( _instance.CamelBazGetterCalled ); + Assert.IsFalse( _instance.CamelUnderscoreFooGetterCalled ); } *************** *** 48,58 **** { Assert.AreEqual( 0, _getter.Get(_instance) ); - _setter.Set( _instance, 5 ); Assert.AreEqual( 5, _getter.Get(_instance) ); } - } - - } --- 52,58 ---- Index: CamelCaseUnderscoreFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/PropertyTest/CamelCaseUnderscoreFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CamelCaseUnderscoreFixture.cs 23 Aug 2004 02:10:31 -0000 1.1 --- CamelCaseUnderscoreFixture.cs 23 Aug 2004 13:13:25 -0000 1.2 *************** *** 17,22 **** { _accessor = PropertyAccessorFactory.GetPropertyAccessor("field.camelcase-underscore"); ! _getter = _accessor.GetGetter( typeof(FieldClass), "Id" ); ! _setter = _accessor.GetSetter( typeof(FieldClass), "Id" ); _instance = new FieldClass(2, 0 , -4, 3 ); } --- 17,22 ---- { _accessor = PropertyAccessorFactory.GetPropertyAccessor("field.camelcase-underscore"); ! _getter = _accessor.GetGetter( typeof(FieldClass), "CamelUnderscoreFoo" ); ! _setter = _accessor.GetSetter( typeof(FieldClass), "CamelUnderscoreFoo" ); _instance = new FieldClass(2, 0 , -4, 3 ); } Index: PascalCaseMUnderscoreFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/PropertyTest/PascalCaseMUnderscoreFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PascalCaseMUnderscoreFixture.cs 23 Aug 2004 02:10:31 -0000 1.1 --- PascalCaseMUnderscoreFixture.cs 23 Aug 2004 13:13:25 -0000 1.2 *************** *** 17,22 **** { _accessor = PropertyAccessorFactory.GetPropertyAccessor("field.pascalcase-m-underscore"); ! _getter = _accessor.GetGetter( typeof(FieldClass), "Id" ); ! _setter = _accessor.GetSetter( typeof(FieldClass), "Id" ); _instance = new FieldClass( 6, -12 , 0, 13); } --- 17,22 ---- { _accessor = PropertyAccessorFactory.GetPropertyAccessor("field.pascalcase-m-underscore"); ! _getter = _accessor.GetGetter( typeof(FieldClass), "Blah" ); ! _setter = _accessor.GetSetter( typeof(FieldClass), "Blah" ); _instance = new FieldClass( 6, -12 , 0, 13); } |