public void MultyNoifyPropertyTest() { var model = new TestModelBase(); var doubleCounter = 0; var otherCounter = 0; model.SetChangedAction(x => x.MultyNotifyProperty, () => doubleCounter++); model.SetChangedAction(x => x.OtherNotifyProperty, () => otherCounter++); model.MultyNotifyProperty = 1; Assert.AreEqual(doubleCounter, 1); Assert.AreEqual(otherCounter, 1); }
public void SimpleNotifyPropertyTest() { var model = new TestModelBase(); var counter = 0; model.SetChangedAction(x => x.NotifyProperty, () => counter++); // modify model.NotifyProperty = 1; Assert.AreEqual(counter, 1); // modify model.NotifyProperty += 2; Assert.AreEqual(counter, 2); // not modify model.NotifyProperty = 3; Assert.AreEqual(counter, 2); // modify other model.OtherNotifyProperty = 100; Assert.AreEqual(counter, 2); Assert.AreEqual(model.NotifyProperty, 3); Assert.AreEqual(model.OtherNotifyProperty, 100); }
public void VirtualNotNotifyPropertyTest() { var model = new TestModelBase(); var counter = 0; model.SetChangedAction(x => x.VirtualNotNotifyProperty, () => counter++); model.VirtualNotNotifyProperty = 1; Assert.AreEqual(counter, 0); }
static WeakReference CreateWeakRef() { var model = new TestModelBase(); var counter = 0; model.SetChangedAction(x => x.NotifyProperty, () => counter++); model.NotifyProperty = 1; Assert.AreEqual(counter, 1); return(new WeakReference(model)); }
public void RefletionTest() { var model = new TestModelBase(); var counter = 0; model.SetChangedAction(x => x.NotifyProperty, () => counter++); Assert.DoesNotThrow(() => { var prop = model.GetType().GetProperty("NotifyProperty"); prop.SetValue(model, 1, null); }); Assert.AreEqual(counter, 1); }
public void DefaultPrecisionFloatNoifyPropertyTest() { var model = new TestModelBase(); var counter = 0; model.SetChangedAction(x => x.FloatNotifyProperty, () => counter++); model.FloatNotifyProperty = 1; Assert.AreEqual(counter, 1); // very small number model.FloatNotifyProperty += 1e-9f; Assert.AreEqual(counter, 1); model.FloatNotifyProperty += 1e-7f; Assert.AreEqual(counter, 2); }