|
From: <fab...@us...> - 2011-03-04 22:46:04
|
Revision: 5419
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=5419&view=rev
Author: fabiomaulo
Date: 2011-03-04 22:45:55 +0000 (Fri, 04 Mar 2011)
Log Message:
-----------
Fix NH-2556 (BREAKING CHANGE)
Modified Paths:
--------------
trunk/nhibernate/releasenotes.txt
trunk/nhibernate/src/NHibernate/Properties/FieldAccessor.cs
trunk/nhibernate/src/NHibernate/PropertyNotFoundException.cs
trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs
trunk/nhibernate/src/NHibernate.DomainModel/NHSpecific/BasicClass.cs
trunk/nhibernate/src/NHibernate.Test/CompositeId/ClassWithCompositeId.hbm.xml
trunk/nhibernate/src/NHibernate.Test/Join/Person.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1831/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1831/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH750/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
trunk/nhibernate/src/NHibernate.Test/PropertyTest/FieldGetterFixture.cs
trunk/nhibernate/src/NHibernate.Test/Unconstrained/SimplyA.cs
trunk/nhibernate/src/NHibernate.Test/Unconstrained/SimplyManyToOneIgnoreTest.cs
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/DogMapping.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/Model.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/PersonMapping.hbm.xml
trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperGetProperty.cs
Modified: trunk/nhibernate/releasenotes.txt
===================================================================
--- trunk/nhibernate/releasenotes.txt 2011-03-04 20:01:08 UTC (rev 5418)
+++ trunk/nhibernate/releasenotes.txt 2011-03-04 22:45:55 UTC (rev 5419)
@@ -1,4 +1,4 @@
-** Known BREAKING CHANGES from NH3.0.0.GA to NH3.0.1.GA
+** Known BREAKING CHANGES from NH3.0.0.GA to NH3.1.0.GA
##### Design time #####
* [NH-2481] - Deprecated: ISession.SaveOrUpdateCopy methods - use ISession.Merge methods instead
@@ -8,6 +8,7 @@
##### Possible Breaking Changes #####
* [NH-2461] - Signature change for IQuery.SetParameterList
+ * [NH-2556] - NH is too tolerante to incorrect naming when access="field.XXX" is used
** Known BREAKING CHANGES from NH2.1.1.GA to NH3.0.0.GA
Modified: trunk/nhibernate/src/NHibernate/Properties/FieldAccessor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Properties/FieldAccessor.cs 2011-03-04 20:01:08 UTC (rev 5418)
+++ trunk/nhibernate/src/NHibernate/Properties/FieldAccessor.cs 2011-03-04 22:45:55 UTC (rev 5419)
@@ -3,6 +3,7 @@
using System.Reflection;
using System.Reflection.Emit;
using NHibernate.Engine;
+using NHibernate.Util;
namespace NHibernate.Properties
{
@@ -63,6 +64,11 @@
public IGetter GetGetter(System.Type theClass, string propertyName)
{
string fieldName = GetFieldName(propertyName);
+ if (!Equals(fieldName, propertyName) && !theClass.HasProperty(propertyName))
+ {
+ // it is a field access that imply the existence of the property
+ throw new PropertyNotFoundException(propertyName, fieldName, theClass);
+ }
return new FieldGetter(GetField(theClass, fieldName), theClass, fieldName);
}
Modified: trunk/nhibernate/src/NHibernate/PropertyNotFoundException.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/PropertyNotFoundException.cs 2011-03-04 20:01:08 UTC (rev 5418)
+++ trunk/nhibernate/src/NHibernate/PropertyNotFoundException.cs 2011-03-04 22:45:55 UTC (rev 5419)
@@ -45,6 +45,15 @@
this.propertyName = propertyName;
}
+ public PropertyNotFoundException(string propertyName, string fieldName, System.Type targetType)
+ : base(String.Format("Could not find the property '{0}', associated to the field '{1}', in class '{2}'", propertyName, fieldName, targetType
+ ))
+ {
+ this.targetType = targetType;
+ this.propertyName = propertyName;
+ accessorType = fieldName;
+ }
+
/// <summary>
/// Initializes a new instance of the <see cref="PropertyNotFoundException"/> class
/// with serialized data.
Modified: trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2011-03-04 20:01:08 UTC (rev 5418)
+++ trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2011-03-04 22:45:55 UTC (rev 5419)
@@ -659,5 +659,35 @@
}
return null;
}
+
+ /// <summary>
+ /// Try to find a property, that can be managed by NHibernate, from a given type.
+ /// </summary>
+ /// <param name="source">The given <see cref="System.Type"/>. </param>
+ /// <param name="propertyName">The name of the property to find.</param>
+ /// <returns>true if the property exists; otherwise false.</returns>
+ /// <remarks>
+ /// When the user defines a field.xxxxx access strategy should be because both the property and the field exists.
+ /// NHibernate can work even when the property does not exist but in this case the user should use the appropiate accessor.
+ /// </remarks>
+ public static bool HasProperty(this System.Type source, string propertyName)
+ {
+ if (source == typeof (object) || source == null)
+ {
+ return false;
+ }
+ if (string.IsNullOrEmpty(propertyName))
+ {
+ return false;
+ }
+
+ PropertyInfo property = source.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);
+
+ if (property != null)
+ {
+ return true;
+ }
+ return HasProperty(source.BaseType, propertyName) || source.GetInterfaces().Any(@interface => HasProperty(@interface, propertyName));
+ }
}
}
Modified: trunk/nhibernate/src/NHibernate.DomainModel/NHSpecific/BasicClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.DomainModel/NHSpecific/BasicClass.cs 2011-03-04 20:01:08 UTC (rev 5418)
+++ trunk/nhibernate/src/NHibernate.DomainModel/NHSpecific/BasicClass.cs 2011-03-04 22:45:55 UTC (rev 5419)
@@ -42,6 +42,11 @@
{
}
+ private int PrivateField
+ {
+ get { return _privateField; }
+ }
+
public int Id
{
get { return _id; }
Modified: trunk/nhibernate/src/NHibernate.Test/CompositeId/ClassWithCompositeId.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/CompositeId/ClassWithCompositeId.hbm.xml 2011-03-04 20:01:08 UTC (rev 5418)
+++ trunk/nhibernate/src/NHibernate.Test/CompositeId/ClassWithCompositeId.hbm.xml 2011-03-04 22:45:55 UTC (rev 5419)
@@ -8,7 +8,7 @@
>
<composite-id name="Id" class="NHibernate.Test.CompositeId.Id, NHibernate.Test" access="nosetter.camelcase-underscore">
<key-property name="KeyString" column="string_" type="String(20)" length="20" />
- <key-property name="KeyShort" column="short_" access="field.camelcase-underscore"/>
+ <key-property name="_keyShort" column="short_" access="field"/>
<key-property name="KeyDateTime" column="date_" type="DateTime" access="nosetter.camelcase-underscore"/>
</composite-id>
Modified: trunk/nhibernate/src/NHibernate.Test/Join/Person.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Join/Person.hbm.xml 2011-03-04 20:01:08 UTC (rev 5418)
+++ trunk/nhibernate/src/NHibernate.Test/Join/Person.hbm.xml 2011-03-04 22:45:55 UTC (rev 5419)
@@ -66,7 +66,7 @@
</join>
<join table="t_silly" fetch="select" optional="true">
<key column="person_id"/>
- <property name="Silly"/>
+ <property name="_Silly" access="field"/>
</join>
</subclass>
</class>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/DogMapping.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/DogMapping.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/DogMapping.hbm.xml 2011-03-04 22:45:55 UTC (rev 5419)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.AccessAndCorrectPropertyName"
+ assembly="NHibernate.Test">
+ <class name="Dog">
+ <id name="Id">
+ <generator class="assigned"/>
+ </id>
+ <property name="Name"
+ access="field.camelcase"/>
+ </class>
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/Fixture.cs 2011-03-04 22:45:55 UTC (rev 5419)
@@ -0,0 +1,30 @@
+using System.Reflection;
+using NHibernate.Cfg;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.AccessAndCorrectPropertyName
+{
+ [TestFixture]
+ public class Fixture
+ {
+ private const string ns = "NHibernate.Test.NHSpecificTest.AccessAndCorrectPropertyName.";
+
+ [Test]
+ public void WrongPropertyNameForCamelcaseUnderscoreShouldThrow()
+ {
+ //default-access="field.camelcase-underscore" on entity
+ var cfg = new Configuration();
+ Assert.Throws<MappingException>(() =>
+ cfg.AddResource(ns + "PersonMapping.hbm.xml", Assembly.GetExecutingAssembly()));
+ }
+
+ [Test]
+ public void WrongPropertyNameForCamelcaseShouldThrow()
+ {
+ //default-access="field.camelcase" on property
+ var cfg = new Configuration();
+ Assert.Throws<MappingException>(() =>
+ cfg.AddResource(ns + "DogMapping.hbm.xml", Assembly.GetExecutingAssembly()));
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/Model.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/Model.cs 2011-03-04 22:45:55 UTC (rev 5419)
@@ -0,0 +1,28 @@
+namespace NHibernate.Test.NHSpecificTest.AccessAndCorrectPropertyName
+{
+ public class Person
+ {
+ private string _firstName;
+
+ public virtual int Id { get; set; }
+
+ public virtual string FiRsTNaMe
+ {
+ get { return _firstName; }
+ set { _firstName = value; }
+ }
+ }
+
+ public class Dog
+ {
+ private string name;
+
+ public virtual int Id { get; set; }
+
+ public virtual string xyz
+ {
+ get { return name; }
+ set { name = value; }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/PersonMapping.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/PersonMapping.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/AccessAndCorrectPropertyName/PersonMapping.hbm.xml 2011-03-04 22:45:55 UTC (rev 5419)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.AccessAndCorrectPropertyName"
+ assembly="NHibernate.Test"
+ default-access="field.camelcase-underscore">
+
+ <class name="Person">
+ <id name="Id"
+ access="property">
+ <generator class="assigned"/>
+ </id>
+ <property name="FirstName"/>
+ </class>
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Mappings.hbm.xml 2011-03-04 20:01:08 UTC (rev 5418)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Mappings.hbm.xml 2011-03-04 22:45:55 UTC (rev 5419)
@@ -4,7 +4,7 @@
namespace="NHibernate.Test.NHSpecificTest.NH1507">
<class name="Employee">
- <id column="EmployeeId" name="Id" access="field.camelcase-underscore">
+ <id column="EmployeeId" name="_id" access="field">
<generator class="identity" />
</id>
<property name="LastName" length="20" not-null="true" />
@@ -31,7 +31,7 @@
</class>
<class name="Order" table="Orders">
- <id column="OrderID" name="Id" access="field.camelcase-underscore">
+ <id column="OrderID" name="_id" access="field">
<generator class="identity" />
</id>
<many-to-one name="Employee" lazy="false" column="EmployeeId"/>
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1831/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1831/Fixture.cs 2011-03-04 20:01:08 UTC (rev 5418)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1831/Fixture.cs 2011-03-04 22:45:55 UTC (rev 5419)
@@ -10,7 +10,7 @@
{
using (var s = OpenSession())
{
- const string hql = @"SELECT dt FROM DocumentType dt WHERE dt.SystemAction & :sysAct = :sysAct ";
+ const string hql = @"SELECT dt FROM DocumentType dt WHERE dt.systemAction & :sysAct = :sysAct ";
s.CreateQuery(hql).SetParameter("sysAct", SystemAction.Denunciation).List();
}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1831/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1831/Mappings.hbm.xml 2011-03-04 20:01:08 UTC (rev 5418)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1831/Mappings.hbm.xml 2011-03-04 22:45:55 UTC (rev 5419)
@@ -4,10 +4,10 @@
default-lazy="false">
<class name="DocumentType" table="documents_documenttype" batch-size="10">
- <id name="oid" type="System.Guid" unsaved-value="00000000-0000-0000-0000-000000000000" access="field.camelcase">
+ <id name="oid" type="System.Guid" unsaved-value="00000000-0000-0000-0000-000000000000" access="field">
<generator class="guid.comb" />
</id>
- <property name="SystemAction" access="field.camelcase"/>
+ <property name="systemAction" access="field"/>
</class>
</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH750/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH750/Mappings.hbm.xml 2011-03-04 20:01:08 UTC (rev 5418)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH750/Mappings.hbm.xml 2011-03-04 22:45:55 UTC (rev 5419)
@@ -5,7 +5,7 @@
default-access="field.camelcase-underscore"
default-lazy="false">
<class name="Device">
- <id name="id" type="Int32">
+ <id name="_id" type="Int32" access="field">
<generator class="native"/>
</id>
<property name="Manifacturer"/>
@@ -16,7 +16,7 @@
</class>
<class name="Drive">
- <id name="id" type="Int32">
+ <id name="_id" type="Int32" access="field">
<generator class="native"/>
</id>
<property name="ClassFullName"/>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-03-04 20:01:08 UTC (rev 5418)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2011-03-04 22:45:55 UTC (rev 5419)
@@ -501,6 +501,8 @@
<Compile Include="Linq\ByMethod\SumTests.cs" />
<Compile Include="Logging\Log4NetLoggerTest.cs" />
<Compile Include="Logging\LoggerProviderTest.cs" />
+ <Compile Include="NHSpecificTest\AccessAndCorrectPropertyName\Fixture.cs" />
+ <Compile Include="NHSpecificTest\AccessAndCorrectPropertyName\Model.cs" />
<Compile Include="NHSpecificTest\BagWithLazyExtraAndFilter\Domain.cs" />
<Compile Include="NHSpecificTest\BagWithLazyExtraAndFilter\Fixture.cs" />
<Compile Include="NHSpecificTest\EntityNameAndCompositeId\Fixture.cs" />
@@ -681,6 +683,7 @@
<Compile Include="UtilityTest\EnumerableExtensionsTests\AnyExtensionTests.cs" />
<Compile Include="UtilityTest\EnumerableExtensionsTests\FirstExtensionTests.cs" />
<Compile Include="UtilityTest\EnumerableExtensionsTests\FirstOrNullExtensionTests.cs" />
+ <Compile Include="UtilityTest\ReflectHelperGetProperty.cs" />
<Compile Include="UtilityTest\ReflectionHelperIsMethodOfTests.cs" />
<Compile Include="UtilityTest\ReflectionHelperTest.cs" />
<Compile Include="Linq\RegresstionTests.cs" />
@@ -2470,6 +2473,8 @@
<EmbeddedResource Include="NHSpecificTest\NH1291AnonExample\Mappings.hbm.xml" />
</ItemGroup>
<ItemGroup>
+ <EmbeddedResource Include="NHSpecificTest\AccessAndCorrectPropertyName\DogMapping.hbm.xml" />
+ <EmbeddedResource Include="NHSpecificTest\AccessAndCorrectPropertyName\PersonMapping.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2507\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\EntityNameAndInheritance\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH2467\Mappings.hbm.xml" />
Modified: trunk/nhibernate/src/NHibernate.Test/PropertyTest/FieldGetterFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/PropertyTest/FieldGetterFixture.cs 2011-03-04 20:01:08 UTC (rev 5418)
+++ trunk/nhibernate/src/NHibernate.Test/PropertyTest/FieldGetterFixture.cs 2011-03-04 22:45:55 UTC (rev 5419)
@@ -104,7 +104,30 @@
private long _propertyfour = Int64.MaxValue;
private decimal m_propertyFive = 2.5m;
#pragma warning restore 414
+ public DateTime PropertyOne
+ {
+ get { return propertyOne; }
+ }
+ public bool PropertyTwo
+ {
+ get { return _propertyTwo; }
+ }
+
+ public TimeSpan PropertyThree
+ {
+ get { return m_PropertyThree; }
+ }
+
+ public long PropertyFour
+ {
+ get { return _propertyfour; }
+ }
+
+ public decimal PropertyFive
+ {
+ get { return m_propertyFive; }
+ }
}
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/Unconstrained/SimplyA.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Unconstrained/SimplyA.cs 2011-03-04 20:01:08 UTC (rev 5418)
+++ trunk/nhibernate/src/NHibernate.Test/Unconstrained/SimplyA.cs 2011-03-04 22:45:55 UTC (rev 5419)
@@ -23,7 +23,7 @@
set { _name = value; }
}
- public SimplyB B
+ public SimplyB SimplyB
{
get { return _simplyB; }
set { _simplyB = value; }
Modified: trunk/nhibernate/src/NHibernate.Test/Unconstrained/SimplyManyToOneIgnoreTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Unconstrained/SimplyManyToOneIgnoreTest.cs 2011-03-04 20:01:08 UTC (rev 5418)
+++ trunk/nhibernate/src/NHibernate.Test/Unconstrained/SimplyManyToOneIgnoreTest.cs 2011-03-04 22:45:55 UTC (rev 5419)
@@ -26,7 +26,7 @@
{
SimplyB sb = new SimplyB(100);
SimplyA sa = new SimplyA("ralph");
- sa.B = sb;
+ sa.SimplyB = sb;
s.Save(sb);
s.Save(sa);
t.Commit();
@@ -47,7 +47,7 @@
using (ITransaction t = s.BeginTransaction())
{
SimplyA sa = (SimplyA) s.Get(typeof(SimplyA), "ralph");
- Assert.IsNull(sa.B);
+ Assert.IsNull(sa.SimplyB);
s.Delete(sa);
t.Commit();
}
Added: trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperGetProperty.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperGetProperty.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperGetProperty.cs 2011-03-04 22:45:55 UTC (rev 5419)
@@ -0,0 +1,82 @@
+using NHibernate.Util;
+using NUnit.Framework;
+using SharpTestsEx;
+
+namespace NHibernate.Test.UtilityTest
+{
+ public class ReflectHelperGetProperty
+ {
+ private class Entity
+ {
+ public int Id { get; set; }
+ }
+ private interface IHasSomething
+ {
+ string Something { get; }
+ }
+ private class Person : Entity, IHasSomething
+ {
+ private string _firstName;
+
+ public string FiRsTNaMe
+ {
+ get { return _firstName; }
+ set { _firstName = value; }
+ }
+
+ #region IHasSomething Members
+
+ string IHasSomething.Something
+ {
+ get { throw new System.NotImplementedException(); }
+ }
+
+ #endregion
+
+ public string Normal { get; set; }
+ }
+
+ [Test]
+ public void WhenNullSourceThenNotFound()
+ {
+ System.Type source= null;
+ source.HasProperty("whatever").Should().Be.False();
+ }
+
+ [Test]
+ public void WhenNullNameThenNotFound()
+ {
+ typeof(Person).HasProperty(null).Should().Be.False();
+ }
+
+ [Test]
+ public void WhenPropertyIsInClassThenFound()
+ {
+ typeof(Person).HasProperty("Normal").Should().Be.True();
+ }
+
+ [Test]
+ public void WhenPropertyIsInBaseClassThenFound()
+ {
+ typeof(Person).HasProperty("Id").Should().Be.True();
+ }
+
+ [Test]
+ public void WhenPropertyIsExplicitImplementationOfInterfaceThenFound()
+ {
+ typeof(Person).HasProperty("Something").Should().Be.True();
+ }
+
+ [Test]
+ public void WhenFieldThenNotFound()
+ {
+ typeof(Person).HasProperty("_firstName").Should().Be.False();
+ }
+
+ [Test]
+ public void WhenPropertyNameWithDifferentCaseThenNotFound()
+ {
+ typeof(Person).HasProperty("FirstName").Should().Be.False();
+ }
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|