public void ShouldGiveNewValueToValueChangedCallbackWhenValueChanges() { var entity = new NotifyingEntity(); var adapter = new ClrPropertyAdapter(entity, NotifyingEntity.PropertyInfo); object value = null; adapter.ValueChangedCallback = newValue => value = newValue; entity.Property = 3; Assert.AreEqual(3, value); }
public void ShouldNotNotifyAboutValueChangesAfterBeingDisposed() { var entity = new NotifyingEntity(); var adapter = new ClrPropertyAdapter(entity, NotifyingEntity.PropertyInfo); var callbackCallCount = 0; adapter.ValueChangedCallback = newValue => ++ callbackCallCount; adapter.Dispose(); entity.Property = 3; Assert.AreEqual(0, callbackCallCount); }
public void ShouldCallValueChangedCallbackWhenValueChanges() { var entity = new NotifyingEntity(); var adapter = new ClrPropertyAdapter(entity, NotifyingEntity.PropertyInfo); var callbackCalled = false; adapter.ValueChangedCallback = newValue => callbackCalled = true; entity.Property = 5; Assert.IsTrue(callbackCalled); }
public void ShouldNotCallValueChangedCallbackWhenSettingValue() { var entity = new NotifyingEntity(); var adapter = new ClrPropertyAdapter(entity, NotifyingEntity.PropertyInfo); bool callbackCalled = false; adapter.ValueChangedCallback = newValue => { callbackCalled = true; }; adapter.SetValue(5); Assert.IsFalse(callbackCalled); }
public void ShouldNotUseOldValueChangedCallbackIfGivenNewOne() { var entity = new NotifyingEntity(); var adapter = new ClrPropertyAdapter(entity, NotifyingEntity.PropertyInfo); var callbackCallCount = 0; adapter.ValueChangedCallback = newValue => ++ callbackCallCount; entity.Property = 5; adapter.ValueChangedCallback = newValue => { }; entity.Property = 3; Assert.AreEqual(1, callbackCallCount); }
public void ShouldDoNothingWithoutValueChangedCallbackWhenValueChanges() { var entity = new NotifyingEntity(); var adapter = new ClrPropertyAdapter(entity, NotifyingEntity.PropertyInfo); try { entity.Property = 5; } catch { Assert.Fail(); } }
public void ShouldDoNothingAfterValueChangedCallbackIsSetToNullWhenValueChanges() { var entity = new NotifyingEntity(); var adapter = new ClrPropertyAdapter(entity, NotifyingEntity.PropertyInfo); adapter.ValueChangedCallback = newValue => { }; adapter.ValueChangedCallback = null; try { entity.Property = 3; } catch { Assert.Fail(); } }