예제 #1
0
        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);
        }
예제 #2
0
        /// <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);
        }
예제 #3
0
        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();
 }
예제 #6
0
 public virtual void Unsubscribe()
 {
     Unsubscriber.Dispose();
 }
예제 #7
0
        public virtual void Unsubscribe(IObserver <WeatherInfo> observer)
        {
            var unsubscriber = new Unsubscriber(Observers, observer);

            unsubscriber.Dispose();
        }