コード例 #1
0
 /// <summary>
 /// Determines whether two collections are equal by checking if they contain the same items, in the any order.
 /// Items equality is determined by comparing each item's properties.
 /// </summary>
 /// <typeparam name="T">The type of items contained in the collections</typeparam>
 /// <param name="collection1">The first collection</param>
 /// <param name="collection2">The second collection</param>
 /// <param name="compareSettings">The comparison options to use when comparing item properties</param>
 /// <returns>Whether the collections are equal</returns>
 public static bool AreCollectionsEquivalentByItemProperties <T>(IEnumerable <T> collection1, IEnumerable <T> collection2,
                                                                 ObjectComparer.ComparisonOptions compareSettings)
     where T : class
 {
     return(AreCollectionsEqual(collection1, collection2, (x, y) => ObjectComparer.ArePropertiesEqual(x, y, compareSettings)));
 }
コード例 #2
0
 /// <summary>
 /// Returns a Moq Match&lt;IEnumerable&lt;<typeparam name="T"></typeparam>&gt;&gt; that can be used with .Setup, .Verify, etc
 /// to match an 'Equivalent' collection.
 /// Note that this overload determines if items are equal by calling using the ObjectComparer to match item property values.
 /// </summary>
 /// <typeparam name="T">The type of items contained in the collections</typeparam>
 /// <param name="expected">The collection to match</param>
 /// <param name="compareSettings">The comparison options to pass to the ObjectComparer. Optional.</param>
 /// <returns>An IEnumerable&lt;T&gt; that can be used with Moq methods.</returns>
 public static IEnumerable <T> MatchEquivalentIEnumerableByItemProperties <T>(IEnumerable <T> expected,
                                                                              ObjectComparer.ComparisonOptions compareSettings = null)
     where T : class
 {
     return(Match.Create <IEnumerable <T> >(l => AreCollectionsEquivalent(expected, l,
                                                                          (x, y) => ObjectComparer.ArePropertiesEqual(x, y, compareSettings))));
 }
コード例 #3
0
 /// <summary>
 /// Set the helper to help with xUnit output for both CollectionComparer and ObjectComparer
 /// </summary>
 /// <param name="testOutputHelper">Test output tester</param>
 public static void SetTestOutputHelper(ITestOutputHelper testOutputHelper)
 {
     _testOutputHelper = testOutputHelper;
     ObjectComparer.SetTestOutputHelper(testOutputHelper);
 }