public void Dispose_WithCollectionContainingInstance_RemovesInstanceFromCollection() { var obj = new object(); var collection = new Collection<object> {obj}; var unsubscriber = new Unsubscriber<object>(obj, collection); unsubscriber.Dispose(); Assert.IsEmpty(collection); }
/// <summary> /// deletes a player on all other clients when said player loses connection to the server /// </summary> /// <param name="cmd">the command containing the details about the player that needs to be deleted</param> public void PlayerDisconnectHandler(DeleteObjectCommand cmd) { game.getWorldObjects().Remove(cmd.obj); Player p = (Player)cmd.obj; Unsubscriber <Command> unsubscriber = new Unsubscriber <Command>(observers, p.GetClient()); unsubscriber.Dispose(); if (game.GetPlayerCount() == 0) { game.Dispose(); } SendCommandsToObservers(cmd); }
public void Dispose() { var mockery = new MockRepository(); var observer = mockery.StrictMock<IObserver<string>>(); var observers = mockery.StrictMock<IList<IObserver<string>>>(); using (mockery.Record()) { Expect.Call(observers.Contains(observer)).Return(true); Expect.Call(observers.Remove(observer)).Return(true); } using (mockery.Playback()) { var unsubscriber = new Unsubscriber<string>(observers, observer); unsubscriber.Dispose(); } }
public void WhenUnsubscribe_ShouldBeDisposed() { var mock1 = new Mock <INotificationObserver <string> >(); var mock2 = new Mock <INotificationObserver <string> >(); var mock3 = new Mock <INotificationObserver <string> >(); var obs = new SynchronizedCollection <INotificationObserver <string> > { mock1.Object, mock2.Object, mock3.Object }; var unsub = new Unsubscriber(obs, mock2.Object); unsub.Dispose(); Assert.Equal(2, obs.Count); Assert.False(obs.Contains(mock2.Object)); }
public virtual void Unsubscribe() { cancellation.Dispose(); }
public virtual void Unsubscribe() { Unsubscriber.Dispose(); }
public virtual void Unsubscribe(IObserver <WeatherInfo> observer) { var unsubscriber = new Unsubscriber(Observers, observer); unsubscriber.Dispose(); }