public void ShouldAcceptChanges()
        {
            var emailToModify = _emails.First();
            var emailToRemove = _emails.Skip(1).First();
            var emailToAdd    = new FriendEmailWrapper(new FriendEmail {
                Email = "*****@*****.**"
            });
            var c = new ChangeTrackingCollection <FriendEmailWrapper>(_emails)
            {
                emailToAdd
            };

            c.Remove(emailToRemove);
            emailToModify.Email = "*****@*****.**";

            Assert.Equal("*****@*****.**", emailToModify.EmailOriginalValue);

            Assert.Equal(2, c.Count);
            Assert.Equal(1, c.AddedItems.Count);
            Assert.Equal(1, c.ModifiedItems.Count);
            Assert.Equal(1, c.RemovedItems.Count);

            c.AcceptChanges();

            Assert.Equal(2, c.Count);
            Assert.True(c.Contains(emailToModify));
            Assert.True(c.Contains(emailToAdd));

            Assert.Equal(0, c.AddedItems.Count);
            Assert.Equal(0, c.ModifiedItems.Count);
            Assert.Equal(0, c.RemovedItems.Count);

            Assert.False(emailToModify.IsChanged);
            Assert.Equal("*****@*****.**", emailToModify.Email);
            Assert.Equal("*****@*****.**", emailToModify.EmailOriginalValue);

            Assert.False(c.IsChanged);
        }
        public void ShouldAcceptChanges()
        {
            Initialize();
            var listItemToAdd = new PocoListItemAdapter(new PocoListItem {
                Id = 3, Title = "TestItem03", Description = "Description03"
            });
            var listItemToModify = _listItems.First();
            var listItemToRemove = _listItems.Skip(1).First();


            var c = new ChangeTrackingCollection <PocoListItemAdapter>(_listItems);

            c.Add(listItemToAdd);
            c.Remove(listItemToRemove);
            listItemToModify.Description = "modified item";
            Assert.Equal("Description01", listItemToModify.DescriptionOriginal);

            Assert.Equal(2, c.Count);
            Assert.Equal(1, c.AddedItems.Count);
            Assert.Equal(1, c.ModifiedItems.Count);
            Assert.Equal(1, c.RemovedItems.Count);

            c.AcceptChanges();

            Assert.Equal(2, c.Count);
            Assert.True(c.Contains(listItemToModify));
            Assert.True(c.Contains(listItemToAdd));

            Assert.Equal(0, c.AddedItems.Count);
            Assert.Equal(0, c.ModifiedItems.Count);
            Assert.Equal(0, c.RemovedItems.Count);

            Assert.False(listItemToModify.IsChanged);
            Assert.Equal("modified item", listItemToModify.Description);
            Assert.Equal("modified item", listItemToModify.DescriptionOriginal);

            Assert.False(c.IsChanged);
        }
        public void ShouldAcceptChanges()
        {
            var emailToModify = _emails.First();
            var emailToRemove = _emails.Skip(1).First();
            var emailToAdd    = new EmailWrapper(new Email {
                EmailAddress = "*****@*****.**"
            });

            var c = new ChangeTrackingCollection <EmailWrapper>(_emails);

            c.Add(emailToAdd);
            c.Remove(emailToRemove);
            emailToModify.EmailAddress = "*****@*****.**";
            Assert.AreEqual("*****@*****.**", emailToModify.EmailAddressOriginalValue);

            Assert.AreEqual(2, c.Count);
            Assert.AreEqual(1, c.AddedItems.Count);
            Assert.AreEqual(1, c.ModifiedItems.Count);
            Assert.AreEqual(1, c.RemovedItems.Count);

            c.AcceptChanges();

            Assert.AreEqual(2, c.Count);
            Assert.IsTrue(c.Contains(emailToModify));
            Assert.IsTrue(c.Contains(emailToAdd));

            Assert.AreEqual(0, c.AddedItems.Count);
            Assert.AreEqual(0, c.ModifiedItems.Count);
            Assert.AreEqual(0, c.RemovedItems.Count);

            Assert.IsFalse(emailToModify.IsChanged);
            Assert.AreEqual("*****@*****.**", emailToModify.EmailAddress);
            Assert.AreEqual("*****@*****.**", emailToModify.EmailAddressOriginalValue);

            Assert.IsFalse(c.IsChanged);
        }
        public void ShouldAcceptChanged()
        {
            var emailToModify = _emails.First();
            var emailToRemove = _emails.Skip(1).First();
            var emailToAdd    = new EmailWrapper(new Email {
                EmailAddress = "*****@*****.**"
            });

            var trackingCollection = new ChangeTrackingCollection <EmailWrapper>(_emails);

            trackingCollection.Add(emailToAdd);
            trackingCollection.Remove(emailToRemove);
            emailToModify.EmailAddress = "*****@*****.**";
            Assert.AreEqual(email1, emailToModify.EmailAddressOriginalValue);

            Assert.AreEqual(2, trackingCollection.Count);
            Assert.AreEqual(1, trackingCollection.AddedItems.Count);
            Assert.AreEqual(1, trackingCollection.ModifiedItems.Count);
            Assert.AreEqual(1, trackingCollection.RemovedItems.Count);

            trackingCollection.AcceptChanges();

            Assert.AreEqual(2, trackingCollection.Count);
            Assert.IsTrue(trackingCollection.Contains(emailToModify));
            Assert.IsTrue(trackingCollection.Contains(emailToAdd));

            Assert.AreEqual(0, trackingCollection.AddedItems.Count);
            Assert.AreEqual(0, trackingCollection.ModifiedItems.Count);
            Assert.AreEqual(0, trackingCollection.RemovedItems.Count);

            Assert.IsFalse(emailToModify.IsChanged);
            Assert.AreEqual("*****@*****.**", emailToModify.EmailAddress);
            Assert.AreEqual("*****@*****.**", emailToModify.EmailAddressOriginalValue);

            Assert.IsFalse(trackingCollection.IsChanged);
        }