コード例 #1
0
        public PlayerTests()
        {
            ConfigurationManager.SetJson(Utility.CONFIGFILE_JSON);

            AlgoFactory.CleanFactories();
            AlgoFactory.AddFactory(AlgoType.Constant);
            AlgoFactory.AddFactory(AlgoType.Exp);
            AlgoFactory.AddFactory(AlgoType.Fibonacci);
            AlgoFactory.AddFactory(AlgoType.Increment);
            AlgoFactory.AddFactory(AlgoType.Multiple);

            UnitFactory.CleanFactories();
            GathererUnitRegister gathererVisitor = new GathererUnitRegister();

            UnitFactory.AddFactory(gathererVisitor);
            BuilderUnitRegister builderVisitor = new BuilderUnitRegister();

            UnitFactory.AddFactory(builderVisitor);
            FarmerUnitRegister farmerVisitor = new FarmerUnitRegister();

            UnitFactory.AddFactory(farmerVisitor);
            ResearcherUnitRegister researcherVisitor = new ResearcherUnitRegister();

            UnitFactory.AddFactory(researcherVisitor);

            BuildingFactory.CleanFactories();

            ForestCampBuildingRegister forestCampVisitor = new ForestCampBuildingRegister();

            BuildingFactory.AddFactory(forestCampVisitor);
            MiningVillageBuildingRegister miningVillageVisitor = new MiningVillageBuildingRegister();

            BuildingFactory.AddFactory(miningVillageVisitor);
            FarmBuildingRegister farmVisitor = new FarmBuildingRegister();

            BuildingFactory.AddFactory(farmVisitor);
            LabBuildingRegister labVisitor = new LabBuildingRegister();

            BuildingFactory.AddFactory(labVisitor);

            Market.ResetMarket();
            Player.GetInstance().ResetPlayer();
        }
コード例 #2
0
        public void CreateLabTest()
        {
            Assert.Throws <Exception>(() => BuildingFactory.CreateBuilding(typeof(Lab)));
            LabBuildingRegister visitor = new LabBuildingRegister();

            BuildingFactory.AddFactory(visitor);
            var building = BuildingFactory.CreateBuilding(typeof(Lab));

            Assert.IsType <Lab>(building);
            var lab = building as Lab;

            Assert.False(lab.AbleToFunction);
            Assert.Equal(10, lab.BuildingTime);
            Assert.Equal(0, lab.BuildProgress);
            Assert.Equal(0, lab.CurrentCapacity);
            Assert.Single(lab.UnitTypes);
            Assert.Equal(typeof(Researcher), lab.UnitTypes.Single());
            Assert.Equal(5, lab.MaxCapacity);
        }
コード例 #3
0
        public void CreateMiningVillageTest()
        {
            Assert.Throws <Exception>(() => BuildingFactory.CreateBuilding(typeof(MiningVillage)));
            MiningVillageBuildingRegister visitor = new MiningVillageBuildingRegister();

            BuildingFactory.AddFactory(visitor);
            var building = BuildingFactory.CreateBuilding(typeof(MiningVillage));

            Assert.IsType <MiningVillage>(building);
            var miningVillage = building as MiningVillage;

            Assert.False(miningVillage.AbleToFunction);
            Assert.Equal(5, miningVillage.BuildingTime);
            Assert.Equal(0, miningVillage.BuildProgress);
            Assert.Equal(0, miningVillage.CurrentCapacity);
            Assert.Single(miningVillage.UnitTypes);
            Assert.Equal(typeof(Gatherer), miningVillage.UnitTypes.Single());
            Assert.Equal(5, miningVillage.MaxCapacity);
        }
コード例 #4
0
        public void CreateFarmTest()
        {
            Assert.Throws <Exception>(() => BuildingFactory.CreateBuilding(typeof(Farm)));
            FarmBuildingRegister visitor = new FarmBuildingRegister();

            BuildingFactory.AddFactory(visitor);
            var building = BuildingFactory.CreateBuilding(typeof(Farm));

            Assert.IsType <Farm>(building);
            var farm = building as Farm;

            Assert.False(farm.AbleToFunction);
            Assert.Equal(7, farm.BuildingTime);
            Assert.Equal(0, farm.BuildProgress);
            Assert.Equal(0, farm.CurrentCapacity);
            Assert.Single(farm.UnitTypes);
            Assert.Equal(typeof(Farmer), farm.UnitTypes.Single());
            Assert.Equal(1, farm.MaxCapacity);
        }
コード例 #5
0
        public void CreateForestCampTest()
        {
            Assert.Throws <Exception>(() => BuildingFactory.CreateBuilding(typeof(ForestCamp)));
            ForestCampBuildingRegister visitor = new ForestCampBuildingRegister();

            BuildingFactory.AddFactory(visitor);
            var building = BuildingFactory.CreateBuilding(typeof(ForestCamp));

            Assert.IsType <ForestCamp>(building);
            var forestCamp = building as ForestCamp;

            Assert.False(forestCamp.AbleToFunction);
            Assert.Equal(5, forestCamp.BuildingTime);
            Assert.Equal(0, forestCamp.BuildProgress);
            Assert.Equal(0, forestCamp.CurrentCapacity);
            Assert.Single(forestCamp.UnitTypes);
            Assert.Equal(typeof(Gatherer), forestCamp.UnitTypes.Single());
            Assert.Equal(5, forestCamp.MaxCapacity);
        }