Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b6bab8f
commit a244eaa
Showing
10 changed files
with
334 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
Src/FluentAssertions/Equivalency/Matching/MappedMemberMatchingRule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
|
||
// <auto-generated/> | ||
using System; | ||
using System.Reflection; | ||
using FluentAssertions.Common; | ||
|
||
namespace FluentAssertions.Equivalency.Matching | ||
{ | ||
internal class MappedMemberMatchingRule : IMemberMatchingRule | ||
{ | ||
private readonly string expectationPropertyPath; | ||
private readonly string subjectPropertyPath; | ||
private Type nestedExpectationType = null; | ||
private readonly string expectationPropertyName; | ||
private Type nestedSubjectType = null; | ||
private readonly string subjectPropertyName; | ||
|
||
public MappedMemberMatchingRule(string expectationPropertyPath, string subjectPropertyPath) | ||
{ | ||
// TODO: What if the property path is empty or null? | ||
// TODO: What if the two paths have a different parent? | ||
|
||
this.expectationPropertyPath = expectationPropertyPath; | ||
this.subjectPropertyPath = subjectPropertyPath; | ||
} | ||
|
||
public MappedMemberMatchingRule(Type expectationType, string expectationPropertyName, Type subjectType, string subjectPropertyName) | ||
{ | ||
// TODO: What if the property is more than just a member name | ||
// TODO: declaredtype vs reflectedtype | ||
|
||
nestedExpectationType = expectationType; | ||
this.expectationPropertyName = expectationPropertyName; | ||
nestedSubjectType = subjectType; | ||
this.subjectPropertyName = subjectPropertyName; | ||
} | ||
|
||
public IMember Match(IMember expectedMember, object subject, INode parent, IEquivalencyAssertionOptions options) | ||
{ | ||
// TODO: What if the subject property does not exist | ||
// TODO: What if the subject is null | ||
// TODO: What if the expectation property does not exist | ||
// TODO: What if the expectation is null | ||
// TODO: What if the subject path is invalid. Can we even verify that? | ||
|
||
if ((expectationPropertyPath.Length > 0) && (expectedMember.PathAndName == expectationPropertyPath)) | ||
{ | ||
|
||
} | ||
|
||
if (expectedMember.ReflectedType.IsSameOrInherits(nestedExpectationType) && subject.GetType() == nestedSubjectType) | ||
{ | ||
if (expectedMember.Name == expectationPropertyName) | ||
{ | ||
return MemberFactory.Create(subject.GetType().GetProperty(subjectPropertyName), parent); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.