Created
February 21, 2012 17:49
-
-
Save ssboisen/1877672 to your computer and use it in GitHub Desktop.
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
public static void ShouldBeStructurallyEqualTo<T, U>(this IEnumerable<T> actual, IEnumerable<U> expected) | |
{ | |
var actualList = actual.ToList(); | |
var expectedList = expected.ToList(); | |
actualList.Should().HaveCount(expectedList.Count()); | |
bool isArrayOfValueType = typeof (T).IsArray && typeof (T).GetElementType().IsValueType; | |
foreach (var pair in actualList.Zip(expectedList, Tuple.Create)) | |
{ | |
if (isArrayOfValueType) | |
(pair.Item1 as IEnumerable).Should().BeEquivalentTo(pair.Item2 as IEnumerable); | |
else | |
pair.Item1.ShouldHave().AllProperties().IncludingNestedObjects().EqualTo(pair.Item2); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment