Esempio n. 1
0
 public void SetupTests()
 {
     sut = new BeeGame();
     var queensRule = new GameRule(0, 1, 100, 8);
     var workersRule = new GameRule(0, 5, 75, 10);
     var dronesRule = new GameRule(0, 8, 50, 12);
     settings = new GameSettings(queensRule, workersRule, dronesRule);
 }
Esempio n. 2
0
        private void GenerateBees(Type beeType, IBee[] container, GameRule rule)
        {
            var random = new Random((int)DateTime.Now.Ticks & 0x0000FFFF);
            do
            {
                var queenPosition = random.Next(0, container.Length);

                if (container[queenPosition] == null)
                {
                    container[queenPosition] = (IBee)Activator.CreateInstance(beeType, new Bee(rule));

                }

            } while (GetBeesNumber(container, beeType) < rule.Elements);
        }
Esempio n. 3
0
        public void Given_SpawnHive_Should_return_two_QueenBees_Invalid()
        {
            //  Arrange
            var sut = new BeeGame();
            var rule = new GameRule(0, 1, 0, 0);

            //  Act
            var result = sut.Start(new GameSettings(new GameRule(0, 2, 0, 0), rule, rule));

            var queen = result.Hive
                .Where(b => b.GetType().Equals(typeof(Queen)))
                .Select(b => b);

            //  Assert
            Assert.IsTrue(queen.Count() != 1);
        }
Esempio n. 4
0
        public void Given_SpawnHive_Should_return_one_QueenBee_Valid()
        {
            //  Arrange
            var sut = new BeeGame();
            var rule = new GameRule(0, 1, 0, 0);

            //  Act
            var result = sut.Start(new GameSettings(rule, rule, rule));

            var queen = result.Hive
                .Where(b => b.GetType().Equals(typeof(Queen)))
                .Select(b => b);

            //  Assert
            Assert.AreEqual(1, queen.Count());
        }
Esempio n. 5
0
 public Bee(GameRule rule) : base()
 {
     LifeSpan = rule.LifeSpan;
     DamageOnHit = rule.Damage;
 }
Esempio n. 6
0
        public void Given_SpawnHive_no_parameters_Should_return_one_QueenBee_null()
        {
            //  Arrange
            var sut = new BeeGame();
            var rule = new GameRule(0, 0, 0, 0);

            //  Act
            try
            {
                var result = sut.Start(new GameSettings(rule, rule, rule));
            }
            catch (Exception e)
            {
                //  Assert
                Assert.AreEqual("Queen Bees Quantity Can't be 0", e.Message);
                throw;
            }
        }
Esempio n. 7
0
        public void Given_SpawnHive_Should_return_one_DroneBees_Invalid()
        {
            //  Arrange
            var sut = new BeeGame();
            var rule = new GameRule(0, 1, 0, 0);

            //  Act
            var result = sut.Start(new GameSettings(rule, new GameRule(0, 2, 0, 0), rule));

            var drones = result.Hive
                .Where(b => b.GetType().Equals(typeof(Drone)))
                .Select(b => b);

            //  Assert
            Assert.IsTrue(drones.Count() != 5);
        }
Esempio n. 8
0
        public void Given_SpawnHive_Should_return_eight_DroneBees_Valid()
        {
            //  Arrange
            var sut = new BeeGame();
            var rule = new GameRule(0, 1, 0, 0);

            //  Act
            var result = sut.Start(new GameSettings(rule, rule, new GameRule(0, 8, 0, 0)));

            var drones = result.Hive
                .Where(b => b.GetType().Equals(typeof(Drone)))
                .Select(b => b);

            //  Assert
            Assert.AreEqual(8, drones.Count());
        }
Esempio n. 9
0
        public void Given_SpawnHive_Should_return_five_WorkerBees_Valid()
        {
            //  Arrange
            var sut = new BeeGame();
            var rule = new GameRule(0, 1, 0, 0);

            //  Act
            var result = sut.Start(new GameSettings(rule, new GameRule(0, 5, 0, 0), rule));

            var workers = result.Hive
                .Where(b => b.GetType().Equals(typeof(Worker)))
                .Select(b => b);

            //  Assert
            Assert.AreEqual(5, workers.Count());
        }
Esempio n. 10
0
 public GameSettings(GameRule queenBees, GameRule workerBees, GameRule droneBees)
 {
     QueenBees = queenBees;
     WorkerBees = workerBees;
     DroneBees = droneBees;
 }