public void TestUpdatesOberserversWhenCoinIsAddedToCoinPurse() { CoinPurse coinPurse = new CoinPurse(); MockCoinPurseObserver mockCoinPurseObserverOne = new MockCoinPurseObserver(); MockCoinPurseObserver mockCoinPurseObserverTwo = new MockCoinPurseObserver(); coinPurse.RegisterObserver(mockCoinPurseObserverOne); coinPurse.RegisterObserver(mockCoinPurseObserverTwo); coinPurse.AddCoin(new MockCoin()); Assert.AreEqual(1, mockCoinPurseObserverOne.NumberOfTimesCoinPurseUpdatedCalled); Assert.AreEqual(1, mockCoinPurseObserverTwo.NumberOfTimesCoinPurseUpdatedCalled); }
public void TestRegisterObserverAddsToObserverList() { CoinPurse coinPurse = new CoinPurse(); MockCoinPurseObserver mockCoinPurseObserver = new MockCoinPurseObserver(); coinPurse.RegisterObserver(mockCoinPurseObserver); Assert.AreEqual(1, coinPurse.Observers.Count); Assert.AreEqual(mockCoinPurseObserver, coinPurse.Observers[0]); }
public void TestClearNotifiesObservers() { CoinPurse coinPurse = new CoinPurse(); MockCoin mockCoin = new MockCoin(); MockCoinPurseObserver mockCoinPurseObserver = new MockCoinPurseObserver(); coinPurse.RegisterObserver(mockCoinPurseObserver); coinPurse.Clear(); Assert.AreEqual(1, mockCoinPurseObserver.NumberOfTimesCoinPurseUpdatedCalled); }