public void IncreasePlayerPositionY_WhenValidParameterIsPassed() { //Arrange var writerMock = new Mock <IWriter>(); var readerMock = new Mock <IReader>(); var appInt = new Mock <IApplicationInterface>(); var drawshipMock = new Mock <IDrawShip>(); appInt.SetupGet(a => a.WindowHeight).Returns(35); var gc = new GameControllerMock(writerMock.Object, readerMock.Object, appInt.Object, drawshipMock.Object); var playerMock = new Mock <IPlayer>(); var spaceshipMock = new Mock <ISpaceShip>(); var spaceship = spaceshipMock.Object; playerMock.SetupGet(p => p.Spaceship).Returns(spaceship); spaceshipMock.SetupAllProperties(); spaceshipMock.SetupGet(s => s.Speed).Returns(1); spaceship.PositionY = 0; // Act gc.ExposedMoveDown(playerMock.Object); //Assert var expected = 1; var result = spaceship.PositionY; Assert.AreEqual(expected, result); }
public void SetIsAtShootingTrue_WhenValidParameterIsPassed() { //Arrange var writerMock = new Mock <IWriter>(); var readerMock = new Mock <IReader>(); var appInt = new Mock <IApplicationInterface>(); var drawshipMock = new Mock <IDrawShip>(); var gc = new GameControllerMock(writerMock.Object, readerMock.Object, appInt.Object, drawshipMock.Object); var playerMock = new Mock <IPlayer>(); var spaceshipMock = new Mock <ISpaceShip>(); var spaceship = spaceshipMock.Object; playerMock.SetupGet(p => p.Spaceship).Returns(spaceship); spaceshipMock.SetupAllProperties(); var weaponMock = new Mock <IWeapon>(); var bulletMock = new Mock <IBullet>(); spaceshipMock.SetupGet(s => s.Weapon).Returns(weaponMock.Object); weaponMock.SetupGet(w => w.Bullet).Returns(bulletMock.Object); spaceship.IsAtShooting = false; //Act gc.ExposedPrepareToShoot(playerMock.Object); //Assert Assert.IsTrue(spaceship.IsAtShooting); }
public void ThrowNullReferenceException_WhenNullSpaceshipIsGiven() { //Arrange var writerMock = new Mock <IWriter>(); var readerMock = new Mock <IReader>(); var appInt = new Mock <IApplicationInterface>(); var drawshipMock = new Mock <IDrawShip>(); var gc = new GameControllerMock(writerMock.Object, readerMock.Object, appInt.Object, drawshipMock.Object); var playerMock = new Mock <IPlayer>(); // Act && Assert Assert.ThrowsException <NullReferenceException>(() => gc.ExposedMoveDown(null)); }