예제 #1
0
파일: ShipsTest.cs 프로젝트: vind113/4X
        public void MinerMine_FromLowerThanTo_FromIsZero()
        {
            double hydrogenFrom     = 1E4;
            double commonMetalsFrom = 1E3;
            double rareElementsFrom = 2E3;

            double hydrogenTo     = 1E5;
            double commonMetalsTo = 1E5;
            double rareElementsTo = 1E5;

            Resources from = new Resources(hydrogenFrom, commonMetalsFrom, rareElementsFrom);
            Resources to   = new Resources(hydrogenTo, commonMetalsTo, rareElementsTo);

            MinerFleet miner = new MinerFleet(10);

            miner.Mine(from, to);

            bool isFromIsZero = from.IsEqual(Resources.Zero);

            bool isToResourcesIncreased = (hydrogenTo < to.Hydrogen) &&
                                          (commonMetalsTo < to.CommonMetals) &&
                                          (rareElementsTo < to.RareEarthElements);

            Assert.IsTrue(isFromIsZero && isToResourcesIncreased);
        }
예제 #2
0
파일: ShipsTest.cs 프로젝트: vind113/4X
        public void MinerMine_FromIsZero_ImmediateReturn()
        {
            Resources from = new Resources(0, 0, 0);

            Resources to = new Resources(1E5, 1E5, 1E5);

            MinerFleet miner = new MinerFleet(10);

            miner.Mine(from, to);

            Assert.IsTrue(from.IsEqual(Resources.Zero));
        }
예제 #3
0
파일: ShipsTest.cs 프로젝트: vind113/4X
        public void MinerMine_FromGreaterThanTo_CorrectExtraction()
        {
            double hydrogenFrom     = 1E6;
            double commonMetalsFrom = 12E6;
            double rareElementsFrom = 23E6;

            double hydrogenTo     = 1E5;
            double commonMetalsTo = 1E5;
            double rareElementsTo = 1E5;

            Resources from = new Resources(hydrogenFrom, commonMetalsFrom, rareElementsFrom);
            Resources to   = new Resources(hydrogenTo, commonMetalsTo, rareElementsTo);

            Resources sumBefore = new Resources(
                from.Hydrogen + to.Hydrogen,
                from.CommonMetals + to.CommonMetals,
                from.RareEarthElements + to.RareEarthElements
                );

            MinerFleet miner = new MinerFleet(10);

            miner.Mine(from, to);

            Resources sumAfter = new Resources(
                from.Hydrogen + to.Hydrogen,
                from.CommonMetals + to.CommonMetals,
                from.RareEarthElements + to.RareEarthElements
                );

            bool isResourcesAmountSame = sumBefore.IsEqual(sumAfter);

            bool isFromResourcesDecreased = (hydrogenFrom > from.Hydrogen) &&
                                            (commonMetalsFrom > from.CommonMetals) &&
                                            (rareElementsFrom > from.RareEarthElements);

            bool isToResourcesIncreased = (hydrogenTo < to.Hydrogen) &&
                                          (commonMetalsTo < to.CommonMetals) &&
                                          (rareElementsTo < to.RareEarthElements);

            Assert.IsTrue(isResourcesAmountSame && isFromResourcesDecreased && isToResourcesIncreased);
        }