public void Remove_AllObservers_AreRemoved() { bool isNotified1 = false; bool isNotified2 = false; ObservableElement <int> obsInt = new ObservableElement <int>(); Observer ob1 = () => isNotified1 = true; Observer ob2 = () => isNotified2 = true; obsInt.AddObserver(ob1); obsInt.AddObserver(ob2); obsInt.RemoveAllObservers(); obsInt.Element = 1; Assert.IsFalse(isNotified1); Assert.IsFalse(isNotified2); }
public void Set_Element_NotifiesObservers() { bool isNotified1 = false; bool isNotified2 = false; ObservableElement <int> obsInt = new ObservableElement <int>(); obsInt.AddObserver(delegate { isNotified1 = true; }); obsInt.AddObserver(delegate { isNotified2 = true; }); obsInt.Element = 1; Assert.IsTrue(isNotified1); Assert.IsTrue(isNotified2); }
public void Add_Obsserver_NotifiesObserver() { bool isNotified = false; ObservableElement <int> obsInt = new ObservableElement <int>(1); obsInt.AddObserver(delegate { isNotified = true; }); obsInt.NotifyObservers(); Assert.IsTrue(isNotified); }
public void SetNoNotifyTest() { ObservableElement <int> obsInt = new ObservableElement <int>(); bool isNotified = false; Observer ob = () => isNotified = true; obsInt.AddObserver(ob); obsInt.SetNoNotify(1); Assert.IsFalse(isNotified); }
public void Remove_Observer_IsRemoved() { bool isNotified = false; ObservableElement <int> obsInt = new ObservableElement <int>(); Observer ob = () => isNotified = true; obsInt.AddObserver(ob); obsInt.RemoveObserver(ob); obsInt.Element = 1; Assert.IsFalse(isNotified); }