Esempio n. 1
0
        public void CanRaiseDestroyedEvent()
        {
            ShipCtrl ship   = new ShipCtrl(Substitute.For <IShipView> ());
            bool     raised = false;

            ship.DestroyedEvent += () => raised = true;

            ship.Destroyed();

            Assert.IsTrue(raised);
        }
Esempio n. 2
0
        public void CanBeDestoyedAndRespawned()
        {
            ShipCtrl ship = new ShipCtrl(Substitute.For <IShipView> ());

            ship.Destroyed();

            Assert.False(ship.IsAlive);
            Assert.False(ship.IsActive);

            ship.Respawn();

            Assert.True(ship.IsAlive);
            Assert.True(ship.IsActive);
        }
Esempio n. 3
0
        public void CannotReactWhileInactive()
        {
            var      view = Substitute.For <IShipView> ();
            ShipCtrl ship = new ShipCtrl(view);

            ship.Destroyed();
            ship.Thrust();
            ship.Rotate(0);
            ship.Teleport();

            view.DidNotReceive().Thrust();
            view.DidNotReceive().Rotate(0);
            view.DidNotReceive().Teleport(Arg.Any <Action> ());

            ship.Respawn();
            ship.Thrust();
            ship.Rotate(0);
            ship.Fire();
            ship.Teleport();

            view.Received(1).Thrust();
            view.Received(1).Rotate(0);
            view.Received(1).Teleport(Arg.Any <Action> ());
        }