public void ShouldPassWhenAllExpectedPropertiesChange() { // arrange var assert = new Asserter(); var subject = new Person(); var expected = "Bob"; // act, asssert (expect setting FirstName also raises event for FullName) assert.PropertyChanged(subject, p => p.FirstName, expected, p => p.FullName); }
public void ShouldPassWhenOnlyOnePropertyChangeIsExpected() { // arrange var assert = new Asserter(); var subject = new Person(); var expected = 123; // act, assert assert.PropertyChanged(subject, p => p.Id, expected); }
public void PropertyChangedShouldAssertNullObject() { // arrange var assert = new Asserter(); var subject = default(Person); try { // act assert.PropertyChanged(subject, p => p.FirstName, string.Empty); } catch (AssertFailedException ex) { // assert Assert.AreEqual(GetExpectedMessage(nameof(subject)), ex.Message); return; } Assert.Fail("An exception was expected, but not thrown."); }
public void ShouldFailWhenSomeOfTheExpectedPropertiesDoNotChange() { // assert var assert = new Asserter(); var subject = new Person(); var expected = "Bob"; try { // act (expect FirstName and FullName, but not LastName) assert.PropertyChanged(subject, p => p.FirstName, expected, p => p.FullName, p => p.LastName); } catch (AssertFailedException) { // assert return; } Assert.Fail("An exception was expected, but not thrown."); }
public void ShouldFailWhenOnePropertyPropertyChangeIsExpectedButMultiplePropertiesChange() { // arrange var assert = new Asserter(); var subject = new Person(); var expected = "Bob"; try { // act (setting the FirstName property also raises FullName property change, but is not expected) assert.PropertyChanged(subject, p => p.FirstName, expected); } catch (AssertFailedException) { // assert return; } Assert.Fail("An exception was expected, but not thrown."); }
public void PropertyChangedShouldAssertNullOtherPropertyExpressions() { // arrange var assert = new Asserter(); var subject = new Person(); var otherProperties = default(Expression <Func <Person, object> >[]); try { // act assert.PropertyChanged(subject, p => p.FirstName, string.Empty, otherProperties); } catch (AssertFailedException ex) { // assert Assert.AreEqual(GetExpectedMessage(nameof(otherProperties)), ex.Message); return; } Assert.Fail("An exception was expected, but not thrown."); }
public void PropertyChangedShouldAssertNullPropertyExpression() { // arrange var assert = new Asserter(); var subject = new Person(); var testProperty = default(Expression <Func <Person, string> >); try { // act assert.PropertyChanged(subject, testProperty, string.Empty); } catch (AssertFailedException ex) { // assert Assert.AreEqual(GetExpectedMessage(nameof(testProperty)), ex.Message); return; } Assert.Fail("An exception was expected, but not thrown."); }