IsDirty flag

BLToolkit.NET

Business Logic Toolkit for .NET www.bltoolkit.net
 

The IsDirty property gets a value that indicates whether the object has changed.

IsDirty.cs
using System;
using NUnit.Framework;
using BLToolkit.EditableObjects;

namespace HowTo.EditableObjects
{
    [TestFixture]
    public class IsDirty
    {
        public abstract class TestObject : EditableObject<TestObject>
        {
            public abstract string FirstName { get; set; }
            public abstract string LastName  { get; set; }
        }

        [Test]
        public void Test()
        {
            TestObject obj = TestObject.CreateInstance();

            Assert.IsFalse(obj.IsDirty);

            obj.FirstName = "Tester";
            obj.LastName  = "Testerson";

            Assert.IsTrue(obj.IsDirty);

            obj.AcceptChanges();

            Assert.IsFalse(obj.IsDirty);
        }
    }
}
 
© 2010 www.bltoolkit.net
[email protected]