Skip to content

Commit

Permalink
SAVEPOINT
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisdoomen committed Nov 13, 2021
1 parent b6bab8f commit cdfcadd
Show file tree
Hide file tree
Showing 9 changed files with 299 additions and 15 deletions.
38 changes: 38 additions & 0 deletions Src/FluentAssertions/Equivalency/EquivalencyAssertionOptions.cs
Expand Up @@ -2,9 +2,11 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;
using FluentAssertions.Common;
using FluentAssertions.Equivalency.Execution;
using FluentAssertions.Equivalency.Matching;
using FluentAssertions.Equivalency.Ordering;
using FluentAssertions.Equivalency.Selection;

Expand Down Expand Up @@ -70,6 +72,42 @@ public EquivalencyAssertionOptions<IEnumerable<TExpectation>> AsCollection()
return new EquivalencyAssertionOptions<IEnumerable<TExpectation>>(
new CollectionMemberAssertionOptionsDecorator(this));
}

public EquivalencyAssertionOptions<TExpectation> WithMapping<TSubject>(
Expression<Func<TExpectation, object>> expectationPropertyPath,
Expression<Func<TSubject, object>> subjectPropertyPath)
{
return WithMapping(
expectationPropertyPath.GetMemberPath().ToString(),
subjectPropertyPath.GetMemberPath().ToString());
}

public EquivalencyAssertionOptions<TExpectation> WithMapping<TNestedExpectation, TNestedSubject>(
Expression<Func<TNestedExpectation, object>> expectationProperty,
Expression<Func<TNestedSubject, object>> subjectProperty)
{
return WithMapping<TNestedExpectation, TNestedSubject>(
expectationProperty.GetMemberPath().ToString(),
subjectProperty.GetMemberPath().ToString());
}

public EquivalencyAssertionOptions<TExpectation> WithMapping(
string expectationPropertyPath,
string subjectPropertyPath)
{
AddMatchingRule(new MappedMemberMatchingRule(expectationPropertyPath, subjectPropertyPath));

return this;
}

public EquivalencyAssertionOptions<TExpectation> WithMapping<TNestedExpectation, TNestedSubject>(
string expectationPropertyName,
string subjectPropertyName)
{
AddMatchingRule(new MappedMemberMatchingRule(typeof(TNestedExpectation), expectationPropertyName, typeof(TNestedSubject), subjectPropertyName));

return this;
}
}

/// <summary>
Expand Down
@@ -0,0 +1,39 @@

// <auto-generated/>
using System;

namespace FluentAssertions.Equivalency.Matching
{
internal class MappedMemberMatchingRule : IMemberMatchingRule
{
private readonly string expectationPropertyPath;
private readonly string subjectPropertyPath;
private Type nestedExpectationType = null;
private Type nestedSubjectType = null;

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

nestedExpectationType = expectationType;
nestedSubjectType = subjectType;
}

public IMember Match(IMember expectedMember, object subject, INode parent, IEquivalencyAssertionOptions options)
{
if (MatchesExpectation(expectedMember))
{

}
}
}
}
Expand Up @@ -820,7 +820,7 @@ protected TSelf AddSelectionRule(IMemberSelectionRule selectionRule)
return (TSelf)this;
}

private TSelf AddMatchingRule(IMemberMatchingRule matchingRule)
protected TSelf AddMatchingRule(IMemberMatchingRule matchingRule)
{
matchingRules.Insert(0, matchingRule);
return (TSelf)this;
Expand Down
Expand Up @@ -751,6 +751,10 @@ namespace FluentAssertions.Equivalency
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<System.Collections.Generic.IEnumerable<TExpectation>> AsCollection() { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> Excluding(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expression) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> Including(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expression) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping(string expectationPropertyPath, string subjectPropertyPath) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping<TSubject>(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expectationProperty, System.Linq.Expressions.Expression<System.Func<TSubject, object>> subjectProperty) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping<TNestedExpectation, TNestedSubject>(System.Linq.Expressions.Expression<System.Func<TNestedExpectation, object>> expectationProperty, System.Linq.Expressions.Expression<System.Func<TNestedSubject, object>> subjectProperty) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping<TNestedExpectation, TNestedSubject>(string expectationPropertyName, string subjectPropertyName) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithStrictOrderingFor(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expression) { }
}
public enum EquivalencyResult
Expand Down
Expand Up @@ -751,6 +751,10 @@ namespace FluentAssertions.Equivalency
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<System.Collections.Generic.IEnumerable<TExpectation>> AsCollection() { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> Excluding(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expression) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> Including(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expression) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping(string expectationPropertyPath, string subjectPropertyPath) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping<TSubject>(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expectationProperty, System.Linq.Expressions.Expression<System.Func<TSubject, object>> subjectProperty) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping<TNestedExpectation, TNestedSubject>(System.Linq.Expressions.Expression<System.Func<TNestedExpectation, object>> expectationProperty, System.Linq.Expressions.Expression<System.Func<TNestedSubject, object>> subjectProperty) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping<TNestedExpectation, TNestedSubject>(string expectationPropertyName, string subjectPropertyName) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithStrictOrderingFor(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expression) { }
}
public enum EquivalencyResult
Expand Down
Expand Up @@ -751,6 +751,10 @@ namespace FluentAssertions.Equivalency
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<System.Collections.Generic.IEnumerable<TExpectation>> AsCollection() { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> Excluding(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expression) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> Including(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expression) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping(string expectationPropertyPath, string subjectPropertyPath) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping<TSubject>(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expectationProperty, System.Linq.Expressions.Expression<System.Func<TSubject, object>> subjectProperty) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping<TNestedExpectation, TNestedSubject>(System.Linq.Expressions.Expression<System.Func<TNestedExpectation, object>> expectationProperty, System.Linq.Expressions.Expression<System.Func<TNestedSubject, object>> subjectProperty) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping<TNestedExpectation, TNestedSubject>(string expectationPropertyName, string subjectPropertyName) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithStrictOrderingFor(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expression) { }
}
public enum EquivalencyResult
Expand Down
Expand Up @@ -744,6 +744,10 @@ namespace FluentAssertions.Equivalency
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<System.Collections.Generic.IEnumerable<TExpectation>> AsCollection() { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> Excluding(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expression) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> Including(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expression) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping(string expectationPropertyPath, string subjectPropertyPath) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping<TSubject>(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expectationProperty, System.Linq.Expressions.Expression<System.Func<TSubject, object>> subjectProperty) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping<TNestedExpectation, TNestedSubject>(System.Linq.Expressions.Expression<System.Func<TNestedExpectation, object>> expectationProperty, System.Linq.Expressions.Expression<System.Func<TNestedSubject, object>> subjectProperty) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping<TNestedExpectation, TNestedSubject>(string expectationPropertyName, string subjectPropertyName) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithStrictOrderingFor(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expression) { }
}
public enum EquivalencyResult
Expand Down
Expand Up @@ -751,6 +751,10 @@ namespace FluentAssertions.Equivalency
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<System.Collections.Generic.IEnumerable<TExpectation>> AsCollection() { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> Excluding(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expression) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> Including(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expression) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping(string expectationPropertyPath, string subjectPropertyPath) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping<TSubject>(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expectationProperty, System.Linq.Expressions.Expression<System.Func<TSubject, object>> subjectProperty) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping<TNestedExpectation, TNestedSubject>(System.Linq.Expressions.Expression<System.Func<TNestedExpectation, object>> expectationProperty, System.Linq.Expressions.Expression<System.Func<TNestedSubject, object>> subjectProperty) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithMapping<TNestedExpectation, TNestedSubject>(string expectationPropertyName, string subjectPropertyName) { }
public FluentAssertions.Equivalency.EquivalencyAssertionOptions<TExpectation> WithStrictOrderingFor(System.Linq.Expressions.Expression<System.Func<TExpectation, object>> expression) { }
}
public enum EquivalencyResult
Expand Down

0 comments on commit cdfcadd

Please sign in to comment.