public void NotifyCommand() { var callbackRaised = false; EventHandler eventHandler = (s, a) => { callbackRaised = true; }; this.TestCommand.CanExecuteChanged += eventHandler; try { this.Property = "Alter Wert"; var monitor = IListenerHostExtensions.Listen(this, v => v.Property) .Notify(() => this.TestCommand); this.Property = "Neuer Wert"; this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(this.Property))); Assert.IsTrue(callbackRaised); } finally { this.TestCommand.CanExecuteChanged -= eventHandler; } }
public void NotifyViewModel() { var callbackRaised = false; PropertyChangedEventHandler eventHandler = (s, a) => { if (a.PropertyName == nameof(this.ViewModel.Property)) { callbackRaised = true; } }; this.ViewModel.PropertyChanged += eventHandler; try { this.Property = "Alter Wert"; var monitor = IListenerHostExtensions.Listen(this, v => v.Property) .Notify(() => this.ViewModel.Property); this.Property = "Neuer Wert"; Assert.IsFalse(callbackRaised); this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(this.Property))); Assert.IsTrue(callbackRaised); } finally { this.ViewModel.PropertyChanged -= eventHandler; } }
public void NotifyViewModel_Fail_Type() { var target = new List <string>(); var monitor = IListenerHostExtensions .Listen(this, v => v.Property) .Notify(() => target.Count); }
public void ListenExpression() { var monitor1 = IListenerHostExtensions.Listen(this, v => v.Property); Assert.IsNotNull(monitor1); var monitor2 = IListenerHostExtensions.Monitor(this, this.ViewModel, v => v.Property); Assert.IsNotNull(monitor2); Assert.AreNotEqual(monitor1, monitor2); }
public void CallBack() { var callbackRaised = false; Action a = () => callbackRaised = true; this.Property = "Alter Wert"; var monitor = IListenerHostExtensions.Listen(this, v => v.Property) .Call(a); this.Property = "Neuer Wert"; Assert.IsFalse(callbackRaised); this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(this.Property))); Assert.IsTrue(callbackRaised); }
public void ListenExpression_Fail_Expression() { var monitor1 = IListenerHostExtensions.Listen(this, v => 42); }
public void NotifyViewModel_Fail_Expression() { var monitor = IListenerHostExtensions .Listen(this, v => v.Property) .Notify(() => 42); }