Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/PropertyTest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5010/NHibernate.Test/PropertyTest Modified Files: FieldAccessorFixture.cs FieldClass.cs FieldGetterFixture.cs NoSetterAccessorFixture.cs NoSetterCamelCaseFixture.cs NoSetterCamelCaseUnderscoreFixture.cs NoSetterPascalCaseMUnderscoreFixture.cs Added Files: FieldCamelCaseFixture.cs FieldCamelCaseUnderscoreFixture.cs FieldLowerCaseUnderscoreFixture.cs FieldPascalCaseMUnderscoreFixture.cs NoSetterLowerCaseUnderscoreFixture.cs Removed Files: CamelCaseFixture.cs CamelCaseUnderscoreFixture.cs PascalCaseMUnderscoreFixture.cs Log Message: NH-118 and a refactoring of TestFixture to make it easier to add new naming strategies for Properties. Index: NoSetterCamelCaseFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/PropertyTest/NoSetterCamelCaseFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NoSetterCamelCaseFixture.cs 23 Aug 2004 13:13:25 -0000 1.1 --- NoSetterCamelCaseFixture.cs 23 Oct 2004 15:44:08 -0000 1.2 *************** *** 20,24 **** _getter = _accessor.GetGetter( typeof(FieldClass), "CamelBaz" ); _setter = _accessor.GetSetter( typeof(FieldClass), "CamelBaz" ); ! _instance = new FieldClass( 6, -1, 2, 0 ); } --- 20,25 ---- _getter = _accessor.GetGetter( typeof(FieldClass), "CamelBaz" ); _setter = _accessor.GetSetter( typeof(FieldClass), "CamelBaz" ); ! _instance = new FieldClass(); ! _instance.InitCamelBaz( 0 ); } --- NEW FILE: FieldLowerCaseUnderscoreFixture.cs --- using System; using NHibernate.Property; using NUnit.Framework; namespace NHibernate.Test.PropertyTest { /// <summary> /// Summary description for FieldLowerCaseUnderscoreFixture. /// </summary> [TestFixture] public class FieldLowerCaseUnderscoreFixture : FieldAccessorFixture { [SetUp] public override void SetUp() { _accessor = PropertyAccessorFactory.GetPropertyAccessor("field.lowercase-underscore"); _getter = _accessor.GetGetter( typeof(FieldClass), "LowerUnderscoreFoo" ); _setter = _accessor.GetSetter( typeof(FieldClass), "LowerUnderscoreFoo" ); _instance = new FieldClass(); _instance.InitLowerUnderscoreFoo( 0 ); } } } --- CamelCaseFixture.cs DELETED --- --- NEW FILE: FieldCamelCaseUnderscoreFixture.cs --- using System; using NHibernate.Property; using NUnit.Framework; namespace NHibernate.Test.PropertyTest { /// <summary> /// Summary description for FieldCamelCaseUnderscoreFixture. /// </summary> [TestFixture] public class FieldCamelCaseUnderscoreFixture : FieldAccessorFixture { [SetUp] public override void SetUp() { _accessor = PropertyAccessorFactory.GetPropertyAccessor("field.camelcase-underscore"); _getter = _accessor.GetGetter( typeof(FieldClass), "CamelUnderscoreFoo" ); _setter = _accessor.GetSetter( typeof(FieldClass), "CamelUnderscoreFoo" ); _instance = new FieldClass(); _instance.InitCamelUnderscoreFoo( 0 ); } } } Index: NoSetterAccessorFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/PropertyTest/NoSetterAccessorFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NoSetterAccessorFixture.cs 23 Aug 2004 13:13:25 -0000 1.1 --- NoSetterAccessorFixture.cs 23 Oct 2004 15:44:08 -0000 1.2 *************** *** 21,24 **** --- 21,25 ---- protected bool _expectedCamelBazGetterCalled = false; protected bool _expectedCamelUnderscoreFooGetterCalled = false; + protected bool _expectedLowerUnderscoreFooGetterCalled = false; /// <summary> *************** *** 40,46 **** --- 41,49 ---- _instance.Increment(); Assert.AreEqual( 1, _getter.Get(_instance) ); + Assert.AreEqual( _expectedBlahGetterCalled, _instance.BlahGetterCalled ); Assert.AreEqual( _expectedCamelBazGetterCalled, _instance.CamelBazGetterCalled ); Assert.AreEqual( _expectedCamelUnderscoreFooGetterCalled, _instance.CamelUnderscoreFooGetterCalled ); + Assert.AreEqual( _expectedLowerUnderscoreFooGetterCalled, _instance.LowerUnderscoreFooGetterCalled ); } --- NEW FILE: FieldCamelCaseFixture.cs --- using System; using NHibernate.Property; using NUnit.Framework; namespace NHibernate.Test.PropertyTest { /// <summary> /// Summary description for FieldCamelCaseFixture. /// </summary> [TestFixture] public class FieldCamelCaseFixture : FieldAccessorFixture { [SetUp] public override void SetUp() { _accessor = PropertyAccessorFactory.GetPropertyAccessor("field.camelcase"); _getter = _accessor.GetGetter( typeof(FieldClass), "CamelBaz" ); _setter = _accessor.GetSetter( typeof(FieldClass), "CamelBaz" ); _instance = new FieldClass(); _instance.InitCamelBaz( 0 ); } } } --- PascalCaseMUnderscoreFixture.cs DELETED --- Index: FieldGetterFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/PropertyTest/FieldGetterFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FieldGetterFixture.cs 23 Oct 2004 15:01:22 -0000 1.1 --- FieldGetterFixture.cs 23 Oct 2004 15:44:08 -0000 1.2 *************** *** 58,61 **** --- 58,74 ---- [Test] + public void LowerCaseUnderscoreNamingStrategy() + { + IGetter fieldGetter = ReflectHelper.GetGetter( typeof(FieldGetterFixture.FieldGetterClass), "PropertyFour" ); + + Assert.IsNotNull( fieldGetter, "should have found getter" ); + Assert.AreEqual( typeof(FieldGetter), fieldGetter.GetType(), "IGetter should be for a field." ); + Assert.AreEqual( typeof(Int64), fieldGetter.ReturnType, "returns Int64." ); + Assert.IsNull( fieldGetter.Property, "no PropertyInfo for fields." ); + Assert.IsNull( fieldGetter.PropertyName, "no Property Names for fields." ); + Assert.AreEqual( Int64.MaxValue, fieldGetter.Get( obj ), "Get() for Int64" ); + } + + [Test] public void PascalCaseMUnderscoreNamingStrategy() { *************** *** 76,79 **** --- 89,93 ---- private bool _propertyTwo = true; private TimeSpan m_PropertyThree = new TimeSpan( DateTime.Parse("2001-01-01" ).Ticks ); + private long _propertyfour = Int64.MaxValue; } } Index: NoSetterCamelCaseUnderscoreFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/PropertyTest/NoSetterCamelCaseUnderscoreFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NoSetterCamelCaseUnderscoreFixture.cs 23 Aug 2004 13:13:25 -0000 1.1 --- NoSetterCamelCaseUnderscoreFixture.cs 23 Oct 2004 15:44:08 -0000 1.2 *************** *** 21,25 **** _getter = _accessor.GetGetter( typeof(FieldClass), "CamelUnderscoreFoo" ); _setter = _accessor.GetSetter( typeof(FieldClass), "CamelUnderscoreFoo" ); ! _instance = new FieldClass( 6, 0, -1, 2 ); } --- 21,26 ---- _getter = _accessor.GetGetter( typeof(FieldClass), "CamelUnderscoreFoo" ); _setter = _accessor.GetSetter( typeof(FieldClass), "CamelUnderscoreFoo" ); ! _instance = new FieldClass(); ! _instance.InitCamelUnderscoreFoo( 0 ); } Index: NoSetterPascalCaseMUnderscoreFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/PropertyTest/NoSetterPascalCaseMUnderscoreFixture.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** NoSetterPascalCaseMUnderscoreFixture.cs 23 Aug 2004 13:13:25 -0000 1.1 --- NoSetterPascalCaseMUnderscoreFixture.cs 23 Oct 2004 15:44:08 -0000 1.2 *************** *** 21,25 **** _getter = _accessor.GetGetter( typeof(FieldClass), "Blah" ); _setter = _accessor.GetSetter( typeof(FieldClass), "Blah" ); ! _instance = new FieldClass( 6, -1, 0, 2 ); } --- 21,26 ---- _getter = _accessor.GetGetter( typeof(FieldClass), "Blah" ); _setter = _accessor.GetSetter( typeof(FieldClass), "Blah" ); ! _instance = new FieldClass(); ! _instance.InitBlah( 0 ); } --- NEW FILE: FieldPascalCaseMUnderscoreFixture.cs --- using System; using NHibernate.Property; using NUnit.Framework; namespace NHibernate.Test.PropertyTest { /// <summary> /// Summary description for FieldPascalCaseMUnderscoreFixture. /// </summary> [TestFixture] public class FieldPascalCaseMUnderscoreFixture : FieldAccessorFixture { [SetUp] public override void SetUp() { _accessor = PropertyAccessorFactory.GetPropertyAccessor("field.pascalcase-m-underscore"); _getter = _accessor.GetGetter( typeof(FieldClass), "Blah" ); _setter = _accessor.GetSetter( typeof(FieldClass), "Blah" ); _instance = new FieldClass(); _instance.InitBlah( 0 ); } } } Index: FieldClass.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/PropertyTest/FieldClass.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FieldClass.cs 23 Aug 2004 13:13:25 -0000 1.3 --- FieldClass.cs 23 Oct 2004 15:44:08 -0000 1.4 *************** *** 8,26 **** public class FieldClass { ! 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; } --- 8,49 ---- public class FieldClass { ! private int Id = 1; ! private int _camelUnderscoreFoo = 2; ! private int m_Blah = 3; ! private int camelBaz = 4; ! private int _lowerunderscorefoo = 5; public bool CamelUnderscoreFooGetterCalled = false; public bool BlahGetterCalled = false; public bool CamelBazGetterCalled = false; + public bool LowerUnderscoreFooGetterCalled = false; ! public FieldClass( ) ! { ! } ! ! public void InitId(int value) { ! Id = value; ! } ! ! public void InitCamelUnderscoreFoo(int value) ! { ! _camelUnderscoreFoo = value; ! } ! ! public void InitBlah(int value) ! { ! m_Blah = value; ! } ! ! public void InitCamelBaz(int value) ! { ! camelBaz = value; ! } ! ! public void InitLowerUnderscoreFoo(int value) ! { ! _lowerunderscorefoo = value; } *************** *** 31,34 **** --- 54,58 ---- m_Blah++; camelBaz++; + _lowerunderscorefoo++; } *************** *** 42,45 **** --- 66,70 ---- } + public int Blah { *************** *** 59,62 **** --- 84,96 ---- } } + + public int LowerUnderscoreFoo + { + get + { + LowerUnderscoreFooGetterCalled = true; + return _lowerunderscorefoo; + } + } } } Index: FieldAccessorFixture.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/PropertyTest/FieldAccessorFixture.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FieldAccessorFixture.cs 23 Aug 2004 13:13:25 -0000 1.3 --- FieldAccessorFixture.cs 23 Oct 2004 15:44:08 -0000 1.4 *************** *** 32,36 **** _getter = _accessor.GetGetter( typeof(FieldClass), "Id" ); _setter = _accessor.GetSetter( typeof(FieldClass), "Id" ); ! _instance = new FieldClass( 0, 6, -1, 2 ); } --- 32,37 ---- _getter = _accessor.GetGetter( typeof(FieldClass), "Id" ); _setter = _accessor.GetSetter( typeof(FieldClass), "Id" ); ! _instance = new FieldClass(); ! _instance.InitId( 0 ); } *************** *** 46,49 **** --- 47,51 ---- Assert.IsFalse( _instance.CamelBazGetterCalled ); Assert.IsFalse( _instance.CamelUnderscoreFooGetterCalled ); + Assert.IsFalse( _instance.LowerUnderscoreFooGetterCalled ); } --- CamelCaseUnderscoreFixture.cs DELETED --- --- NEW FILE: NoSetterLowerCaseUnderscoreFixture.cs --- using System; using NHibernate.Property; using NUnit.Framework; namespace NHibernate.Test.PropertyTest { /// <summary> /// Summary description for NoSetterLowerCaseUnderscoreFixture. /// </summary> [TestFixture] public class NoSetterLowerCaseUnderscoreFixture : NoSetterAccessorFixture { [SetUp] public override void SetUp() { _expectedLowerUnderscoreFooGetterCalled = true; _accessor = PropertyAccessorFactory.GetPropertyAccessor("nosetter.lowercase-underscore"); _getter = _accessor.GetGetter( typeof(FieldClass), "LowerUnderscoreFoo" ); _setter = _accessor.GetSetter( typeof(FieldClass), "LowerUnderscoreFoo" ); _instance = new FieldClass(); _instance.InitLowerUnderscoreFoo( 0 ); } } } |