Skip to content

EditableObjects.IsDirty

Igor Tkachev edited this page May 20, 2016 · 1 revision

Home / EditableObjects

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);
        }
    }
}
Clone this wiki locally