示例#1
0
        public void ForestCampBuildTest2()
        {
            ForestCamp forestCamp = new ForestCamp(5, 3);
            Builder    builder    = (Builder)UnitFactory.CreateUnit(typeof(Builder));

            Assert.False(forestCamp.AbleToFunction);
            Assert.Equal(3, forestCamp.BuildingTime);
            Assert.Equal(0, forestCamp.BuildProgress);
            Assert.Equal(0, forestCamp.CurrentCapacity);
            Assert.Equal(5, forestCamp.MaxCapacity);
            Assert.Equal(0, forestCamp.CurrentConstructionUnitCount);
            Assert.Single(forestCamp.UnitTypes);
            Assert.Single(forestCamp.UnitTypes.Where(u => u == typeof(Gatherer)));

            forestCamp.DoBuildProcess();
            Assert.Equal(0, forestCamp.BuildProgress);

            forestCamp.AddConstructionUnit(builder);
            Assert.Equal(1, forestCamp.CurrentConstructionUnitCount);
            forestCamp.DoBuildProcess();
            Assert.Equal(1, forestCamp.BuildProgress);
            Assert.False(forestCamp.AbleToFunction);

            forestCamp.DoBuildProcess();
            Assert.Equal(2, forestCamp.BuildProgress);
            Assert.False(forestCamp.AbleToFunction);

            forestCamp.DoBuildProcess();
            Assert.Equal(3, forestCamp.BuildProgress);
            Assert.True(forestCamp.AbleToFunction);
        }
示例#2
0
        public void ForestCampTest()
        {
            ForestCamp forestCamp = new ForestCamp(5, 1);
            Builder    builder    = (Builder)UnitFactory.CreateUnit(typeof(Builder));
            Gatherer   gatherer   = (Gatherer)UnitFactory.CreateUnit(typeof(Gatherer));

            Assert.False(forestCamp.AbleToFunction);
            Assert.Equal(1, forestCamp.BuildingTime);
            Assert.Equal(0, forestCamp.BuildProgress);
            Assert.Equal(0, forestCamp.CurrentCapacity);
            Assert.Equal(5, forestCamp.MaxCapacity);
            Assert.Equal(0, forestCamp.CurrentConstructionUnitCount);
            Assert.Single(forestCamp.UnitTypes);
            Assert.Single(forestCamp.UnitTypes.Where(u => u == typeof(Gatherer)));

            forestCamp.AddConstructionUnit(builder);
            Assert.Equal(1, forestCamp.CurrentConstructionUnitCount);
            var removed = forestCamp.RemoveLastConstructionUnit();

            Assert.Equal(builder, removed);
            Assert.Equal(0, forestCamp.CurrentConstructionUnitCount);

            forestCamp.AddConstructionUnit(builder);
            Assert.Equal(1, forestCamp.CurrentConstructionUnitCount);
            forestCamp.DoBuildProcess();
            Assert.Equal(1, forestCamp.BuildProgress);
            Assert.True(forestCamp.AbleToFunction);

            forestCamp.AssignUnit(gatherer);
            Assert.Equal(1, forestCamp.CurrentCapacity);
            var resources = forestCamp.DoWork();

            Assert.NotNull(resources);
            Assert.NotEmpty(resources);
            Assert.Single(resources);
            Assert.Single(resources.Where(r => r.Type == "wood"));
            Assert.Single(resources.Where(r => r.Type == "wood" && r.Amount == 1));
        }