Permalink
Browse files

Fixing tests

  • Loading branch information...
1 parent dff86bb commit a1bde92d239c6ba5465f4a27482eb0c2e7c511de @aaronjensen aaronjensen committed Nov 21, 2009
@@ -1,10 +1,10 @@
using System.Reflection;
using System.Security;
-[assembly: AssemblyCopyright("Copyright 2008-2009 James Gregory and contributors (Paul Batum, Andrew Stewart, Hudson Akridge, Stuart Childs et al). All rights reserved.")]
+[assembly: AllowPartiallyTrustedCallers]
[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyCompany("http://fluentnhibernate.org")]
[assembly: AssemblyInformationalVersion("1.0.0.0")]
-[assembly: AllowPartiallyTrustedCallers]
[assembly: AssemblyProduct("FluentNHibernate")]
+[assembly: AssemblyCopyright("Copyright 2008-2009 James Gregory and contributors (Paul Batum, Andrew Stewart, Hudson Akridge, Stuart Childs et al). All rights reserved.")]
+[assembly: AssemblyCompany("http://fluentnhibernate.org")]
@@ -129,7 +129,7 @@ public virtual void MapEverythingInClass(ClassMappingBase mapping, Type entityTy
protected void TryToMapProperty(ClassMappingBase mapping, Member property, IList<string> mappedProperties)
{
- if (property.HasIndexParameters)
+ if (!property.HasIndexParameters)
{
foreach (var rule in mappingRules)
{
@@ -56,7 +56,7 @@ public string TableName
public bool IsMethodAccess
{
- get { return mapping.Member is MethodInfo; }
+ get { return mapping.Member.IsMethod; }
}
public MemberInfo Member
@@ -6,21 +6,70 @@
namespace FluentNHibernate
{
- public abstract class Member
+ public abstract class Member : IEquatable<Member>
{
public abstract string Name { get; }
public abstract Type PropertyType { get; }
public abstract bool CanWrite { get; }
public abstract MemberInfo MemberInfo { get; }
public abstract Type DeclaringType { get; }
public abstract bool HasIndexParameters { get; }
+ public abstract bool IsMethod { get; }
+ public abstract bool IsField { get; }
+ public abstract bool IsProperty { get; }
// GetIndexParameters().Length == 0
+
+ public bool Equals(Member other)
+ {
+ return !ReferenceEquals(null, other);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof(Member)) return false;
+ return Equals((Member)obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return 0;
+ }
+
+ public static bool operator ==(Member left, Member right)
+ {
+ return Equals(left, right);
+ }
+
+ public static bool operator !=(Member left, Member right)
+ {
+ return !Equals(left, right);
+ }
}
internal class FieldMember : Member
{
private readonly FieldInfo _fieldInfo;
+ public bool Equals(FieldMember other)
+ {
+ return !ReferenceEquals(null, other);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof(FieldMember)) return false;
+ return Equals((FieldMember)obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return 0;
+ }
+
public FieldMember(FieldInfo fieldInfo)
{
_fieldInfo = fieldInfo;
@@ -50,12 +99,42 @@ public override bool HasIndexParameters
{
get { return false; }
}
+ public override bool IsMethod
+ {
+ get { return false; }
+ }
+ public override bool IsField
+ {
+ get { return true; }
+ }
+ public override bool IsProperty
+ {
+ get { return false; }
+ }
}
internal class MethodMember : Member
{
private readonly MethodInfo _methodInfo;
+ public bool Equals(MethodMember other)
+ {
+ return !ReferenceEquals(null, other);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof(MethodMember)) return false;
+ return Equals((MethodMember)obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return 0;
+ }
+
public MethodMember(MethodInfo propertyInfo)
{
_methodInfo = propertyInfo;
@@ -85,6 +164,18 @@ public override bool HasIndexParameters
{
get { return false; }
}
+ public override bool IsMethod
+ {
+ get { return true; }
+ }
+ public override bool IsField
+ {
+ get { return false; }
+ }
+ public override bool IsProperty
+ {
+ get { return false; }
+ }
}
internal class PropertyMember : Member
@@ -96,6 +187,24 @@ public PropertyMember(PropertyInfo propertyInfo)
_propertyInfo = propertyInfo;
}
+ public bool Equals(PropertyMember other)
+ {
+ return !ReferenceEquals(null, other);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof(PropertyMember)) return false;
+ return Equals((PropertyMember)obj);
+ }
+
+ public override int GetHashCode()
+ {
+ return 0;
+ }
+
public override string Name
{
get { return _propertyInfo.Name; }
@@ -120,6 +229,18 @@ public override bool HasIndexParameters
{
get { return _propertyInfo.GetIndexParameters().Length > 0; }
}
+ public override bool IsMethod
+ {
+ get { return false; }
+ }
+ public override bool IsField
+ {
+ get { return false; }
+ }
+ public override bool IsProperty
+ {
+ get { return true; }
+ }
}
public static class MemberExtensions
@@ -107,7 +107,7 @@ public virtual ICollectionMapping GetCollectionMapping()
private string GetDefaultName()
{
- if (member is MethodInfo)
+ if (member.IsMethod)
{
// try to guess the backing field name (GetSomething -> something)
if (member.Name.StartsWith("Get"))

0 comments on commit a1bde92

Please sign in to comment.