Example #1
0
        public void ShouldRaiseErrorsChangedEventWhenFirstNameIsSetToEmptyAndBack()
        {
            var wrapper = new TestFriendWrapper(_testFriend);

            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.FirstName), () => wrapper.FirstName = ""));
            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.FirstName), () => wrapper.FirstName = "Julia"));
        }
Example #2
0
        public void ShouldRaisePropertyChangedEventForIsValidOfRoot()
        {
            var wrapper = new TestFriendWrapper(_testFriend);

            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.IsValid), () => wrapper.Emails.First().Email = ""));
            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.IsValid), () => wrapper.Emails.First().Email = "*****@*****.**"));
        }
Example #3
0
        public void ShouldRaisePropertyChangedEventForIsValidOfRootWhenRemovingInvalidItem()
        {
            var wrapper = new TestFriendWrapper(_testFriend);

            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.IsValid), () => wrapper.Emails.First().Email = ""));
            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.IsValid), () => wrapper.Emails.Remove(wrapper.Emails.First())));
        }
Example #4
0
        public void ShouldRaisePropertyChangedEventForIsValidOfRootWhenAddingInvalidItem()
        {
            var wrapper    = new TestFriendWrapper(_testFriend);
            var emailToAdd = new TestFriendEmailWrapper(new TestFriendEmail());

            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.IsValid), () => wrapper.Emails.Add(emailToAdd)));
            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.IsValid), () => emailToAdd.Email = "*****@*****.**"));
        }
        public void ShouldRaisePropertyChangedEventForIsValidOfRoot()
        {
            var wrapper = new TestFriendWrapper(_testFriend);

            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.IsValid), () => wrapper.TestFriendAddress.City = ""));

            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.IsValid), () => wrapper.TestFriendAddress.City = "Salt Lake City"));
        }
Example #6
0
        public void ShouldRaisePropertyChangedEventForIsValid()
        {
            var wrapper = new TestFriendWrapper(_testFriend);

            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.IsValid), () => wrapper.FirstName = ""));

            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.IsValid), () => wrapper.FirstName = "Julia"));
        }
        public void ShouldRaisePropertyChangedEventForChangeOrRemovePropertyOfFriendTestWrapper()
        {
            var wrapper       = new TestFriendWrapper(_testFriend);
            var originAddress = wrapper.TestFriendAddress;

            Assert.IsFalse(wrapper.PropertyChangedEventRised(nameof(wrapper.IsChanged), () => wrapper.TestFriendAddress = originAddress));
            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.IsChanged), () => wrapper.TestFriendAddress  = new TestFriendAddressWrapper(new TestFriendAddress())));
            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.IsChanged), () => wrapper.TestFriendAddress  = null));
        }
        public void ShouldRaisePropertyChangedEventForIsChangedPropertyOfFriendTestWrapper()
        {
            var wrapper = new TestFriendWrapper(_testFriend);

            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.IsChanged), () => wrapper.TestFriendAddress.City = "Salt Lake City"));

            var originAddress = wrapper.TestFriendAddress;

            wrapper.TestFriendAddress = new TestFriendAddressWrapper(new TestFriendAddress());
            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.IsChanged), () => wrapper.TestFriendAddress.City = "Yekaterinburg"));
            Assert.IsFalse(wrapper.PropertyChangedEventRised(nameof(wrapper.IsChanged), () => originAddress.City            = "Yekaterinburg"));
        }
        public void ShouldRiseEventIfComplexPropertyChanged()
        {
            Assert.IsFalse(_testFriendWrapper.IsChanged);

            var oldAddress = _testFriendWrapper.TestFriendAddress;
            var newAddress = new TestFriendAddress {
                City = "CityNew"
            };

            Assert.IsTrue(_testFriendWrapper.PropertyChangedEventRised(nameof(_testFriendWrapper.TestFriendAddress),
                                                                       () => _testFriendWrapper.TestFriendAddress = new TestFriendAddressWrapper(newAddress)));

            Assert.IsTrue(_testFriendWrapper.IsChanged);

            Assert.IsTrue(_testFriendWrapper.PropertyChangedEventRised(nameof(_testFriendWrapper.TestFriendAddress),
                                                                       () => _testFriendWrapper.TestFriendAddress = oldAddress));
            Assert.IsFalse(_testFriendWrapper.IsChanged);

            Assert.IsFalse(_testFriendWrapper.PropertyChangedEventRised(nameof(_testFriendWrapper.TestFriendAddress),
                                                                        () => _testFriendWrapper.TestFriendAddress = new TestFriendAddressWrapper(oldAddress.Model)));
            Assert.IsFalse(_testFriendWrapper.IsChanged);
        }
        public void ShouldNotRaisePropertyChangedEventIfPropertyIsSetToSameValue()
        {
            var wrapper = new TestFriendWrapper(_testFriend);

            Assert.IsFalse(wrapper.PropertyChangedEventRised(nameof(wrapper.FirstName), () => wrapper.FirstName = "Thomas"));
        }
        public void ShouldRaisePropertyChangedEventForIsChangedPropertyOfFriendTestWrapper()
        {
            var wrapper = new TestFriendWrapper(_testFriend);

            Assert.IsTrue(wrapper.PropertyChangedEventRised(nameof(wrapper.IsChanged), () => wrapper.Emails.First().Email = "*****@*****.**"));
        }