Mercurial > pub > bltoolkit
view UnitTests/CS/EditableObjects/NotifyPropertyChangedTest.cs @ 9:1e85f66cf767 default tip
update bltoolkit
author | nickolay |
---|---|
date | Thu, 05 Apr 2018 20:53:26 +0300 |
parents | f990fcb411a9 |
children |
line wrap: on
line source
using System; using System.ComponentModel; using System.Reflection; using BLToolkit.Reflection; using BLToolkit.TypeBuilder; using NUnit.Framework; namespace EditableObjects { [TestFixture] public class NotifyPropertyChangedTest { [PropertyChanged] public abstract class ObservableObject : INotifyPropertyChanged, IPropertyChanged { #region Implementation of IPropertyChanged public event PropertyChangedEventHandler PropertyChanged; #endregion public abstract int ID { get; set; } public abstract string Name { get; set; } public abstract int Seconds { get; set; } public static ObservableObject CreateInstance() { return TypeAccessor<ObservableObject>.CreateInstance(); } #region Implementation of IPropertyChanged void IPropertyChanged.OnPropertyChanged(PropertyInfo propertyInfo) { OnPropertyChanged(propertyInfo.Name); } #endregion protected internal virtual void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } [Test] public void TestPropertyChangedFired() { ObservableObject obj = ObservableObject.CreateInstance(); bool propertyChangedFired = false; obj.PropertyChanged += delegate { propertyChangedFired = true; }; obj.Name = "this should fire PropertyChanged event"; Assert.That(propertyChangedFired); } } }