private static void CompareMember(IMember expectationMember, Comparands comparands, IEquivalencyValidator parent, IEquivalencyValidationContext context) { IMember matchingMember = FindMatchFor(expectationMember, comparands.Subject, context); if (matchingMember is not null) { var nestedComparands = new Comparands { Subject = matchingMember.GetValue(comparands.Subject), Expectation = expectationMember.GetValue(comparands.Expectation), CompileTimeType = expectationMember.Type }; if (context.AsNestedMember(expectationMember) is not null) { parent.RecursivelyAssertEquality(nestedComparands, context.AsNestedMember(expectationMember)); } } }
private static void AssertMemberEquality(Comparands comparands, IEquivalencyValidationContext context, IEquivalencyValidator parent, IMember selectedMember, IEquivalencyAssertionOptions options) { IMember matchingMember = FindMatchFor(selectedMember, context.CurrentNode, comparands.Subject, options); if (matchingMember is not null) { var nestedComparands = new Comparands { Subject = matchingMember.GetValue(comparands.Subject), Expectation = selectedMember.GetValue(comparands.Expectation), CompileTimeType = selectedMember.Type }; parent.RecursivelyAssertEquality(nestedComparands, context.AsNestedMember(selectedMember)); } }
private static void CompareDataRelationKeyConstraint(DataRelation subject, DataRelation expectation, IEquivalencyValidator parent, IEquivalencyValidationContext context, Dictionary <string, IMember> selectedMembers, string relationDirection) { if (selectedMembers.TryGetValue(relationDirection + "KeyConstraint", out IMember expectationMember)) { IMember subjectMember = FindMatchFor(expectationMember, context.CurrentNode, subject, context.Options); var newComparands = new Comparands { Subject = subjectMember.GetValue(subject), Expectation = expectationMember.GetValue(expectation), CompileTimeType = expectationMember.Type }; parent.RecursivelyAssertEquality(newComparands, context.AsNestedMember(expectationMember)); } }
private static void CompareCollections(IEquivalencyValidationContext context, Comparands comparands, IEquivalencyValidator parent, IEquivalencyAssertionOptions config, Dictionary <string, IMember> selectedMembers) { if (selectedMembers.TryGetValue(nameof(DataRelation.ExtendedProperties), out IMember expectationMember)) { IMember matchingMember = FindMatchFor(expectationMember, context.CurrentNode, comparands.Subject, config); if (matchingMember is not null) { var nestedComparands = new Comparands { Subject = matchingMember.GetValue(comparands.Subject), Expectation = expectationMember.GetValue(comparands.Expectation), CompileTimeType = expectationMember.Type }; parent.RecursivelyAssertEquality(nestedComparands, context.AsNestedMember(expectationMember)); } } }
private static void CompareCollections(Comparands comparands, IEquivalencyValidationContext context, IEquivalencyValidator parent, IEquivalencyAssertionOptions config, Dictionary <string, IMember> selectedMembers) { // Note: The collections here are listed in the XML documentation for the DataTable.BeEquivalentTo extension // method in DataTableAssertions.cs. If this ever needs to change, keep them in sync. var collectionNames = new[] { nameof(DataTable.ChildRelations), nameof(DataTable.Columns), nameof(DataTable.Constraints), nameof(DataTable.ExtendedProperties), nameof(DataTable.ParentRelations), nameof(DataTable.PrimaryKey), nameof(DataTable.Rows), }; foreach (var collectionName in collectionNames) { if (selectedMembers.TryGetValue(collectionName, out IMember expectationMember)) { IMember matchingMember = FindMatchFor(expectationMember, comparands.Subject, context.CurrentNode, config); if (matchingMember is not null) { IEquivalencyValidationContext nestedContext = context.AsNestedMember(expectationMember); var nestedComparands = new Comparands { Subject = matchingMember.GetValue(comparands.Subject), Expectation = expectationMember.GetValue(comparands.Expectation), CompileTimeType = expectationMember.Type }; parent.RecursivelyAssertEquality(nestedComparands, nestedContext); } } } }
private static void AssertMemberEquality(Comparands comparands, IEquivalencyValidationContext context, IEquivalencyValidator parent, IMember selectedMember, IEquivalencyAssertionOptions options) { IMember matchingMember = FindMatchFor(selectedMember, context.CurrentNode, comparands.Subject, options); if (matchingMember is not null) { var nestedComparands = new Comparands { Subject = matchingMember.GetValue(comparands.Subject), Expectation = selectedMember.GetValue(comparands.Expectation), CompileTimeType = selectedMember.Type }; if (selectedMember.Name != matchingMember.Name) { // In case the matching process selected a different member on the subject, // adjust the current member so that assertion failures report the proper name. selectedMember.Name = matchingMember.Name; } parent.RecursivelyAssertEquality(nestedComparands, context.AsNestedMember(selectedMember)); } }