public void Update_DoesntRemoveOffScreenPlayer()
        {
            var screen = new Mock<ITiledScreen>();
            screen.Setup(s => s.IsOnScreen(It.IsAny<float>(), It.IsAny<float>())).Returns(false);
            _entityMock.SetupGet(e => e.Screen).Returns(screen.Object);

            _entityMock.SetupGet(e => e.Name).Returns("Player");

            var removed = false;
            _entityMock.Setup(e => e.Remove()).Callback(() => { removed = true; });

            var container = new FakeGameplayContainer();
            _position.Start(container);

            container.Tick();

            Assert.IsFalse(removed);
        }
        public void Update_DoesntRemoveOnScreen()
        {
            var screen = new Mock <ITiledScreen>();

            screen.Setup(s => s.IsOnScreen(It.IsAny <float>(), It.IsAny <float>())).Returns(true);
            _entityMock.SetupGet(e => e.Screen).Returns(screen.Object);

            var removed = false;

            _entityMock.Setup(e => e.Remove()).Callback(() => { removed = true; });

            var container = new FakeGameplayContainer();

            _position.Start(container);

            container.Tick();

            Assert.IsFalse(removed);
        }
Beispiel #3
0
        public void Movement_DoesNotAcceptVelocityChangeWhenPaused()
        {
            _screen.Setup(s => s.TileAt(It.IsAny <int>(), It.IsAny <int>())).Returns((Tile)null);

            _movement.Start(_container);
            Assert.AreEqual(0, _movement.VelocityX);

            _entityMock.SetupGet(x => x.Paused).Returns(true);
            _movement.VelocityX = 5;
            _container.Tick();
            Assert.AreEqual(0, _movement.VelocityX);

            _entityMock.SetupGet(x => x.Paused).Returns(false);
            _movement.CanMove   = false;
            _movement.VelocityX = 5;
            _container.Tick();
            Assert.AreEqual(0, _movement.VelocityX);
        }