Пример #1
0
        public void ShouldPassWhenPropertyExpectedNotToChangeRemainsUnchanged()
        {
            // arrange
            var assert   = new Asserter();
            var expected = "Bob";
            var subject  = new Person()
            {
                FirstName = expected
            };

            // act, assert
            assert.PropertyNotChanged(subject, p => p.FirstName, expected);
        }
Пример #2
0
        public void PropertyNotChangedShouldAssertNullObject()
        {
            // arrange
            var assert  = new Asserter();
            var subject = default(Person);

            try
            {
                // act
                assert.PropertyNotChanged(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.");
        }
Пример #3
0
        public void PropertyNotChangedShouldAssertNullPropertyExpression()
        {
            // arrange
            var assert       = new Asserter();
            var subject      = new Person();
            var testProperty = default(Expression <Func <Person, string> >);

            try
            {
                // act
                assert.PropertyNotChanged(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.");
        }
Пример #4
0
        public void ShouldFailWhenPropertyExpectedNotToChangeHasChanged()
        {
            // arrange
            var assert  = new Asserter();
            var subject = new Person()
            {
                FirstName = "Bob"
            };

            try
            {
                // act
                assert.PropertyNotChanged(subject, p => p.FirstName, "John");
            }
            catch (AssertFailedException)
            {
                // assert
                return;
            }

            Assert.Fail("An exception was expected, but not thrown.");
        }