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); }
/// <summary> /// Инициализирует экземпляр класса звездной системы /// </summary> /// <param name="name"></param> /// <param name="systemStars"></param> /// <param name="planets"></param> public StarSystem(string name, IList <Star> stars, IList <Planet> planets) { this.Name = name ?? throw new ArgumentNullException(nameof(name)); this.systemStars = new List <Star>(stars) ?? throw new ArgumentNullException(nameof(stars)); if (planets.Count > 255) { throw new ArgumentOutOfRangeException(nameof(planets), "Count can't be greater than 255"); } this.systemPlanets = new List <Planet>(planets) ?? throw new ArgumentNullException(nameof(planets)); this.Buildings = new SystemBuildings(); this.systemMiners = new MinerFleet(); foreach (var planet in this.SystemPlanets) { planet.PropertyChanged += this.Planet_PropertyChanged; } this.SetSystemPopulation(); this.ColonizedCount = this.SetColonizedPlantes(); SetMiners(); this.SystemResources = new StarSystemResourceGenerator().GenerateResources(); }
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)); }
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); }