Esempio n. 1
0
        public void ShouldRejectChanges()
        {
            var wrapper = new TestFriendWrapper(_testFriend);

            wrapper.TestFriendAddress.City = "Salt Lake City";
            Assert.AreEqual("Müllheim", wrapper.TestFriendAddress.CityOriginalValue);

            wrapper.RejectChanges();

            Assert.IsFalse(wrapper.IsChanged);
            Assert.AreEqual("Müllheim", wrapper.TestFriendAddress.City);
            Assert.AreEqual("Müllheim", wrapper.TestFriendAddress.CityOriginalValue);
        }
Esempio n. 2
0
        public void ShouldRejectChanges()
        {
            var wrapper = new TestFriendWrapper(_testFriend);

            var emailToModify = wrapper.Emails.First();

            emailToModify.Email = "*****@*****.**";

            Assert.IsTrue(wrapper.IsChanged);

            wrapper.RejectChanges();

            Assert.IsFalse(wrapper.IsChanged);
            Assert.AreEqual("*****@*****.**", emailToModify.Email);
            Assert.AreEqual("*****@*****.**", emailToModify.EmailOriginalValue);
        }
        public void ShouldRejectChanges()
        {
            var wrapper = new TestFriendWrapper(_testFriend);

            wrapper.FirstName = "Julia";
            Assert.AreEqual("Julia", wrapper.FirstName);
            Assert.AreEqual("Thomas", wrapper.FirstNameOriginalValue);
            Assert.IsTrue(wrapper.FirstNameIsChanged);
            Assert.IsTrue(wrapper.IsChanged);

            wrapper.RejectChanges();

            Assert.AreEqual("Thomas", wrapper.FirstName);
            Assert.AreEqual("Thomas", wrapper.FirstNameOriginalValue);
            Assert.IsFalse(wrapper.FirstNameIsChanged);
            Assert.IsFalse(wrapper.IsChanged);
        }
Esempio n. 4
0
        public void ShouldRefreshErrorsAndIsValidWhenRejectingChanges()
        {
            var wrapper = new TestFriendWrapper(_testFriend);

            Assert.IsTrue(wrapper.IsValid);
            Assert.IsFalse(wrapper.HasErrors);

            wrapper.FirstName = "";

            Assert.IsFalse(wrapper.IsValid);
            Assert.IsTrue(wrapper.HasErrors);

            wrapper.RejectChanges();

            Assert.IsTrue(wrapper.IsValid);
            Assert.IsFalse(wrapper.HasErrors);
        }
        public void ShouldRejectChangesOfComplexProperties()
        {
            var wrapper = new TestFriendWrapper(_testFriend);
            var address = _testFriend.TestFriendAddress;

            wrapper.TestFriendAddress = new TestFriendAddressWrapper(new TestFriendAddress());
            wrapper.RejectChanges();
            Assert.AreEqual(wrapper.Model.TestFriendAddress, address);
            Assert.AreEqual(wrapper.TestFriendAddress.Model, address);

            _testFriend.TestFriendAddress = null;
            wrapper = new TestFriendWrapper(_testFriend);
            address = _testFriend.TestFriendAddress;
            wrapper.TestFriendAddress = new TestFriendAddressWrapper(new TestFriendAddress());
            wrapper.RejectChanges();
            Assert.AreEqual(wrapper.Model.TestFriendAddress, address);
            Assert.AreEqual(wrapper.TestFriendAddress?.Model, address);
        }