public void addFood(int x, int y, bool isBuff, PowerUpType powerUpType, int random) { AbstractPowerUpFactory powerUpFactory = PowerUpFactoryProducer.getFactory(isBuff); PowerUp sizePowerUp = powerUpFactory.getPowerUp(x, y, powerUpType, random); PowerUps.Add(sizePowerUp); }
public override PowerUp generatePowerUp(int mapHeight, int mapWidth) { Random rnd = new Random(); AbstractPowerUpFactory powerUpFactory = PowerUpFactoryProducer.getFactory(rnd.Next(100) > 30? true : false); PowerUp powerUp = powerUpFactory.getPowerUp(rnd.Next(8, mapHeight - 8), rnd.Next(8, mapWidth - 8), PowerUpType.Size, rnd.Next(0, 100)); return(powerUp); }
public void addFood_StateUnderTest_ExpectedBehavior() { // Arrange var map = this.CreateMap(); int x = 0; int y = 0; bool isBuff = false; PowerUpType powerUpType = default(global::Snake.Objects.PowerUps.PowerUpType); AbstractPowerUpFactory powerUpFactory = PowerUpFactoryProducer.getFactory(isBuff); PowerUp sizePowerUp = powerUpFactory.getPowerUp(x, y, powerUpType); // Act map.addFood( x, y, isBuff, powerUpType); // Assert Assert.True(map.PowerUps[0].GetType() == sizePowerUp.GetType() && map.PowerUps[0].X == sizePowerUp.X && map.PowerUps[0].Y == sizePowerUp.Y); this.mockRepository.VerifyAll(); }