public void When_TotalWeightCall_Should_ReturnTotalWeigh() { IPart part = new ShellPart("Cannon-KA2", 300, 500, 450); vehicle.AddShellPart(part); Assert.That(vehicle.TotalWeight, Is.EqualTo(400)); }
public void TestVehicleStatistices() { //Shell part effects on vehicle's weight, price and defense; IPart shellPart = new ShellPart("Shell3", 100, 100, 100); vehcleForStatistics.AddShellPart(shellPart); string actual = vehcleForStatistics.ToString(); string expected = "Vanguard - Statistical\r\nTotal Weight: 200.000\r\n" + "Total Price: 200.000\r\nAttack: 100\r\nDefense: 200\r\n" + "HitPoints: 100\r\nParts: Shell3"; Assert.AreEqual(expected, actual); //Shell part effects on vehicle's weight, price and attack; IPart arsenalPart = new ArsenalPart("Ars", 100, 100, 100); vehcleForStatistics.AddArsenalPart(arsenalPart); actual = vehcleForStatistics.ToString(); expected = "Vanguard - Statistical\r\nTotal Weight: 300.000\r\n" + "Total Price: 300.000\r\nAttack: 200\r\nDefense: 200\r\n" + "HitPoints: 100\r\nParts: Shell3, Ars"; Assert.AreEqual(expected, actual); //Endurance part effects on vehicle's weight, price and hitpoints; IPart endurancePart = new EndurancePart("Endur", 100, 100, 100); vehcleForStatistics.AddEndurancePart(endurancePart); actual = vehcleForStatistics.ToString(); expected = "Vanguard - Statistical\r\nTotal Weight: 400.000\r\n" + "Total Price: 400.000\r\nAttack: 200\r\nDefense: 200\r\n" + "HitPoints: 200\r\nParts: Shell3, Ars, Endur"; Assert.AreEqual(expected, actual); }
public string AddPart(IList <string> arguments) { string vehicleModel = arguments[0]; string partType = arguments[1]; string model = arguments[2]; double weight = double.Parse(arguments[3]); decimal price = decimal.Parse(arguments[4]); int additionalParameter = int.Parse(arguments[5]); IPart part = this.partFactory.CreatePart(partType, model, weight, price, additionalParameter); IVehicle vehicle = this.vehicles[vehicleModel]; if (part != null) { switch (partType) { case "Arsenal": vehicle.AddArsenalPart(part); break; case "Endurance": vehicle.AddEndurancePart(part); break; case "Shell": vehicle.AddShellPart(part); break; default: break; } this.parts.Add(part.Model, part); } return(string.Format( GlobalConstants.PartSuccessMessage, partType, part.Model, vehicleModel)); }