Skip to content

Instantly share code, notes, and snippets.

@dennisdoomen
Created July 24, 2013 19:14
Show Gist options
  • Save dennisdoomen/6073558 to your computer and use it in GitHub Desktop.
Save dennisdoomen/6073558 to your computer and use it in GitHub Desktop.
[TestMethod]
public void When_a_nested_collection_is_unordered_but_order_is_strict_it_should_fail()
{
//-----------------------------------------------------------------------------------------------------------
// Arrange
//-----------------------------------------------------------------------------------------------------------
var subject = new[]
{
new
{
Name = "John",
UnorderedCollection = new[] { 1, 2, 3, 4, 5}
},
new
{
Name = "Jane",
UnorderedCollection = new int[0]
}
};
var expectation = new[]
{
new
{
Name = "John",
UnorderedCollection = new[] { 5, 4, 3, 2, 1}
},
new
{
Name = "Jane",
UnorderedCollection = new int[0]
},
};
//-----------------------------------------------------------------------------------------------------------
// Act
//-----------------------------------------------------------------------------------------------------------
Action action = () => subject.ShouldAllBeEquivalentTo(expectation, options => options
.WithStrictOrderingFor(s => s.UnorderedCollection));
//-----------------------------------------------------------------------------------------------------------
// Assert
//-----------------------------------------------------------------------------------------------------------
action.ShouldThrow<AssertFailedException>();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment