Created
July 5, 2011 21:02
-
-
Save scichelli/1065926 to your computer and use it in GitHub Desktop.
First two fail (as expected), but with an unexpected error message, e.g., "For Customer, expected <>f__AnonymousType3`1[System.String]:[{ Name = Expected Name }] but found ExpectedObjectsAssertions.Customer."
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
[TestFixture] | |
public class When_testing_equivalence_or_matching_for_partially_supplied_properties | |
{ | |
private const string ExpectedName = "Expected Name"; | |
private Customer _actual; | |
private ExpectedObject _expected; | |
[Test] | |
public void Should_flag_extra_properties_on_actual_object_as_unequal() | |
{ | |
_actual = new Customer {Name = ExpectedName, PhoneNumber = "1234567890"}; | |
_expected = new {Name = ExpectedName}.ToExpectedObject(); | |
_expected.ShouldEqual(_actual); | |
} | |
[Test] | |
public void Should_flag_uninitialized_properties_on_actual_object_as_unequal() | |
{ | |
_actual = new Customer {Name = ExpectedName}; | |
_expected = new {Name = ExpectedName, PhoneNumber = "1234567890"}.ToExpectedObject(); | |
_expected.ShouldEqual(_actual); | |
} | |
[Test] | |
public void Should_flag_uninitialized_properties_on_actual_object_as_not_matching() | |
{ | |
_actual = new Customer {Name = ExpectedName}; | |
_expected = new {Name = ExpectedName, PhoneNumber = "1234567890"}.ToExpectedObject(); | |
_expected.ShouldMatch(_actual); //fails as expected | |
} | |
[Test] | |
public void Should_ignore_extra_properties_on_actual_object_when_matching() | |
{ | |
_actual = new Customer {Name = ExpectedName, PhoneNumber = "1234567890"}; | |
_expected = new {Name = ExpectedName}.ToExpectedObject(); | |
_expected.ShouldMatch(_actual); //passes as expected | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment