public void Observer_OC_SubscriberNotCalledAfterBeingRemoved() { Newspaper_OC herald = new Newspaper_OC("Herald"); Subscriber_OC subscriber1 = new Subscriber_OC(); herald.RegisterObserver(subscriber1); // not called before being resistered: herald.NewIssue("issue number 1"); herald.UnregisterObserver(subscriber1); herald.NewIssue("issue number 2"); Assert.AreEqual(1, subscriber1.LatestIssueNumber); }
public void Observer_OC_TwoSubscribers_SubcribersCalled() { Newspaper_OC herald = new Newspaper_OC("Herald"); Subscriber_OC subscriber1 = new Subscriber_OC(); Subscriber_OC subscriber2 = new Subscriber_OC(); herald.RegisterObserver(subscriber1); herald.RegisterObserver(subscriber2); herald.NewIssue("issue number 1"); herald.NewIssue("issue number 2"); Assert.AreEqual(2, subscriber1.LatestIssueNumber); Assert.AreEqual(2, subscriber2.LatestIssueNumber); }
public void Observer_OC_SubscriberNotCalledBeforeRegistered() { Newspaper_OC herald = new Newspaper_OC("Herald"); Subscriber_OC subscriber1 = new Subscriber_OC(); // not called before being resistered: herald.NewIssue("issue number 1"); Assert.AreEqual(0, subscriber1.LatestIssueNumber); }