Exemple #1
0
        public void GathererDefaultProduceTest()
        {
            Gatherer gatherer = new Gatherer(1, new List <ResourceAmount>()
            {
                new ResourceAmount("wood", 1),
                new ResourceAmount("rock", 1)
            },
                                             new List <ResourceAmount>()
            {
                new ResourceAmount("wood", 1),
                new ResourceAmount("rock", 1),
            });

            Assert.Empty(gatherer.Produce());

            gatherer.SwitchState(new WoodcutterState());

            var woods = gatherer.Produce();

            Assert.Single(woods);
            Assert.Single(woods.Where(p => p.Type == "wood"));
            Assert.Equal(1, woods.Where(p => p.Type == "wood").Single().Amount);

            gatherer.SwitchState(new MinerState());

            var rocks = gatherer.Produce();

            Assert.Single(rocks);
            Assert.Single(rocks.Where(p => p.Type == "rock"));
            Assert.Equal(1, rocks.Where(p => p.Type == "rock").Single().Amount);
        }
Exemple #2
0
        public void GathererDefaultUpgradesTest()
        {
            Gatherer gatherer = new Gatherer(1, new List <ResourceAmount>()
            {
                new ResourceAmount("wood", 1),
                new ResourceAmount("rock", 1),
                new ResourceAmount("ore", 1)
            },
                                             new List <ResourceAmount>()
            {
                new ResourceAmount("wood", 1),
                new ResourceAmount("rock", 1),
            });

            Assert.Empty(gatherer.Produce());

            gatherer.SwitchState(new WoodcutterState());

            var woods = gatherer.Produce();

            Assert.Single(woods);
            Assert.Single(woods.Where(p => p.Type == "wood"));
            Assert.Equal(1, woods.Where(p => p.Type == "wood").Single().Amount);

            gatherer.SwitchState(new MinerState());

            var rocks = gatherer.Produce();

            Assert.Single(rocks);
            Assert.Single(rocks.Where(p => p.Type == "rock"));
            Assert.Equal(1, rocks.Where(p => p.Type == "rock").Single().Amount);

            gatherer.SwitchState(new FreeState());
            Assert.Empty(gatherer.Produce());

            gatherer.UpgradeProducerAmount(new ResourceAmount("wood", 2));

            gatherer.SwitchState(new WoodcutterState());

            woods = gatherer.Produce();
            Assert.Single(woods);
            Assert.Single(woods.Where(p => p.Type == "wood"));
            Assert.Equal(3, woods.Where(p => p.Type == "wood").Single().Amount);

            gatherer.UpgradeProducerProduct("ore");
            gatherer.SwitchState(new MinerState());

            var minerResults = gatherer.Produce();

            Assert.Equal(2, minerResults.Count);
            Assert.Single(minerResults.Where(p => p.Type == "rock"));
            Assert.Equal(1, minerResults.Where(p => p.Type == "rock").Single().Amount);
            Assert.Single(minerResults.Where(p => p.Type == "ore"));
            Assert.Equal(1, minerResults.Where(p => p.Type == "ore").Single().Amount);

            gatherer.UpgradeProducerAmount(new ResourceAmount("ore", 4));

            minerResults = gatherer.Produce();
            Assert.Equal(2, minerResults.Count);
            Assert.Single(minerResults.Where(p => p.Type == "rock"));
            Assert.Equal(1, minerResults.Where(p => p.Type == "rock").Single().Amount);
            Assert.Single(minerResults.Where(p => p.Type == "ore"));
            Assert.Equal(5, minerResults.Where(p => p.Type == "ore").Single().Amount);
        }