public void When_TotalHitPointsCall_ShouldReturnTotalHitPoints() { IPart part = new EndurancePart("Cannon-KA2", 300, 500, 450); vehicle.AddEndurancePart(part); Assert.That(vehicle.TotalHitPoints, Is.EqualTo(2450)); }
public void When_PartsCall_ShouldReturnPointsCollection() { IPart part = new EndurancePart("Cannon-KA2", 300, 500, 450); vehicle.AddEndurancePart(part); Assert.That(vehicle.Parts.Count, Is.EqualTo(1)); }
public void CheckOverrideToString() { string model = "Rhino-CE"; double weight = 12; decimal price = 19; int attack = 80; int defense = 11; int hitPoints = 3; IAssembler assembler = new VehicleAssembler(); BaseVehicle testVehicle = new Revenger(model, weight, price, attack, defense, hitPoints, assembler); IPart arsenalPart = new ArsenalPart("arse1", 1, 1, 2); testVehicle.AddArsenalPart(arsenalPart); IPart shellPart = new ShellPart("hel1", 6, 1, 8); testVehicle.AddShellPart(shellPart); IPart endurancePart = new EndurancePart("end1", 1, 3, 2); testVehicle.AddEndurancePart(endurancePart); string expectedMessage = "Revenger - Rhino-CE\r\nTotal Weight: 20.000\r\nTotal Price: 24.000\r\nAttack: 82\r\nDefense: 19\r\nHitPoints: 5\r\nParts: arse1, hel1, end1"; string actualMessage = testVehicle.ToString(); Assert.AreEqual(expectedMessage, actualMessage); }
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 void TestMethods() { // All Valid var vehicle = new Vanguard("SA-203", 100, 300, 1000, 450, 2000, new VehicleAssembler()); var arsenalPart = new ArsenalPart("Arsenal", 100, 300, 1000); var shellPart = new ShellPart("Shell", 100, 300, 1000); var shellTwoPart = new ShellPart("Shell2", 100, 300, 1000); var endurancePart = new EndurancePart("Endurance", 100, 300, 1000); // Test If AddArsenalPart adds new part vehicle.AddArsenalPart(arsenalPart); // Test If AddShellPart adds new part vehicle.AddShellPart(shellPart); vehicle.AddShellPart(shellTwoPart); // Test if AddEndurancePart adds new part vehicle.AddEndurancePart(endurancePart); var partsList = (List <IPart>)vehicle.Parts; string[] modelsList = new string[] { "Arsenal", "Shell", "Shell2", "Endurance" }; var typesList = new string[] { "ArsenalPart", "ShellPart", "ShellPart", "EndurancePart" }; for (int index = 0; index < partsList.Count; index++) { Assert.AreEqual(partsList[index].Model, modelsList[index]); Assert.AreEqual(partsList[index].GetType().Name, typesList[index], "Incorrect part type!"); } }
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 = null; switch (partType) { case "Arsenal": part = new ArsenalPart(model, weight, price, additionalParameter); this.vehicles[vehicleModel].AddArsenalPart(part); break; case "Shell": var shellPart = new ShellPart(); this.vehicles[vehicleModel].AddShellPart(part); break; case "Endurance": part = new EndurancePart(model, weight, price, additionalParameter); this.vehicles[vehicleModel].AddEndurancePart(part); break; } return(string.Format( GlobalConstants.PartSuccessMessage, partType, part.Model, vehicleModel)); }
public void BaseVehicleTest() { IAssembler assembler = new VehicleAssembler(); IVehicle vanguard = new Vanguard("Vanguard1", 500, 1000, 500, 500, 1000, assembler); IPart arsenalPart = new ArsenalPart("Arsenal1", 100, 100, 100); IPart shellPart = new ShellPart("Shell1", 100, 100, 100); IPart endurancePart = new EndurancePart("Endurance1", 100, 100, 100); vanguard.AddArsenalPart(arsenalPart); vanguard.AddEndurancePart(endurancePart); vanguard.AddShellPart(shellPart); double totalWeight = vanguard.TotalWeight; decimal totalPrice = vanguard.TotalPrice; long totalAttack = vanguard.TotalAttack; long totalDefense = vanguard.TotalDefense; long totalHitPoints = vanguard.TotalHitPoints; Assert.That(totalWeight, Is.EqualTo(800).NoClip); Assert.That(totalPrice, Is.EqualTo(1300).NoClip); Assert.That(totalAttack, Is.EqualTo(600).NoClip); Assert.That(totalDefense, Is.EqualTo(600).NoClip); Assert.That(totalHitPoints, Is.EqualTo(1100).NoClip); string expectedResult = "Vanguard - Vanguard1\r\nTotal Weight: 800.000\r\nTotal Price: 1300.000\r\nAttack: 600\r\nDefense: 600\r\nHitPoints: 1100\r\nParts: Arsenal1, Endurance1, Shell1"; string actualResult = vanguard.ToString(); Assert.That(expectedResult, Is.EqualTo(actualResult).NoClip); }
public void ValidateCalculatedProperty() { IVehicle vehicle = new Vanguard("SA-203", 100.00, 300m, 1000, 450, 2000, new VehicleAssembler()); IPart arsenalPart = new ArsenalPart("Cannon-KA2", 300, 500, 450); IPart shellPart = new ShellPart("Shields-PI1", 200, 1000, 750); IPart endurancePart = new EndurancePart("endurance", 200, 1000, 750); double actualResultTotalWeight = 100; Assert.AreEqual(actualResultTotalWeight, vehicle.TotalWeight); decimal actualResultTotalPrice = 300; Assert.AreEqual(actualResultTotalPrice, vehicle.TotalPrice); long actualResultTotalAttack = 1000; Assert.AreEqual(actualResultTotalAttack, vehicle.TotalAttack); long actualResultTotalDefense = 450; Assert.AreEqual(actualResultTotalDefense, vehicle.TotalDefense); long actualResultTotalHitPoints = 2000; Assert.AreEqual(actualResultTotalHitPoints, vehicle.TotalHitPoints); }
public void ShouldAddEndurancePart() { IPart endurancePart = new EndurancePart (partModel, partWeight, partPrice, attackMod); IVehicle vehicle = new Vanguard(model, weight, price, attack, defense, hitPoints, assembler); vehicle.AddEndurancePart(endurancePart); Assert.That(vehicle.TotalHitPoints > hitPoints); }
public void CheckAddEndurancePartToAssembler() { assembler = new VehicleAssembler(); IHitPointsModifyingPart endurancePart = new EndurancePart("enduranceModel", 100, 700m, 30); orderedParts = new List <string>(); this.assembler.AddEndurancePart(endurancePart); this.orderedParts.Add(endurancePart.Model); Assert.That(orderedParts.Count == 1); Assert.That(assembler.EnduranceParts.Count == 1); }
public void AddEndurancePartShouldAddThePartToAssembler() { //Arrange var part = new EndurancePart("part", 10, 10, 10); IAssembler assembler = new VehicleAssembler(); IVehicle vehicle = new Revenger("revenger", 10, 10, 10, 10, 10, assembler); //Action vehicle.AddEndurancePart(part); bool assemblerHasPart = assembler.EnduranceParts.Any(ap => ap.Equals(part)); //Assert Assert.AreEqual(true, assemblerHasPart); }
public void CheckToString() { IVehicle vehicle = new Revenger("asd", 1, 3, 1, 3, 4, new VehicleAssembler()); var arsenal = new ArsenalPart("asd", 12, 3, 4); var endurance = new EndurancePart("asd", 3, 3, 4); var shell = new ShellPart("asd", 3, 3, 4); vehicle.AddEndurancePart(endurance); vehicle.AddArsenalPart(arsenal); vehicle.AddShellPart(shell); Assert.That(vehicle.Parts, Has.Member(arsenal)); Assert.That(vehicle.Parts, Has.Member(endurance)); Assert.That(vehicle.Parts, Has.Member(shell)); }
public void AddEndurancePart_ShouldAddPartCorrectly(string model, double weight, decimal price, int attack, int defense, int hitPoints) { var vehicle = new Revenger(model, weight, price, attack, defense, hitPoints, new VehicleAssembler()); IPart endurancePart = new EndurancePart(model, weight, price, 10); vehicle.AddEndurancePart(endurancePart); var expected = 1; var actual = vehicle.Parts.Count(); Assert.AreEqual(expected, actual); }
public void TotalHitPointsShouldReturnCorrectValue() { var part = new EndurancePart("model", 10, 10, 100); IAssembler assembler = new VehicleAssembler(); assembler.AddEndurancePart(part); IVehicle v = new Revenger("revenger", 10, 10, 10, 10, 10, assembler); var expectedVehicleTotal = v.HitPoints + assembler.TotalHitPointModification; var actualVehicleTotal = v.TotalHitPoints; Assert.AreEqual(expectedVehicleTotal, actualVehicleTotal); }
public string AddPart(IList <string> arguments) { string vehicleModel = arguments[0]; string partType = arguments[1] + "Part"; string model = arguments[2]; double weight = double.Parse(arguments[3]); decimal price = decimal.Parse(arguments[4]); int additionalParameter = int.Parse(arguments[5]); IPart part = null; part = this.partFactory.CreatePart(partType, model, weight, price, additionalParameter); //string partToMethod = "Add" + partType + "Part"; //var type = typeof(VehicleAssembler); //var instance = Activator.CreateInstance(type, true); //var methodI = type.GetMethods().FirstOrDefault(m => m.Name == partToMethod); //var invoke = methodI.Invoke(vehicles[vehicleModel]., new object[] { part }); //this.vehicles[vehicleModel].AddShellPart(part); switch (partType) { case "ArsenalPart": part = new ArsenalPart(model, weight, price, additionalParameter); this.vehicles[vehicleModel].AddArsenalPart(part); this.parts.Add(model, part); break; case "ShellPart": part = new ShellPart(model, weight, price, additionalParameter); this.vehicles[vehicleModel].AddShellPart(part); this.parts.Add(model, part); break; case "EndurancePart": part = new EndurancePart(model, weight, price, additionalParameter); this.vehicles[vehicleModel].AddEndurancePart(part); this.parts.Add(model, part); break; } return(string.Format( GlobalConstants.PartSuccessMessage, partType, part.Model, vehicleModel)); }
public void Test1() { ArsenalPart arsenalPart = new ArsenalPart("model", 0.5, 2.555m, 20); ShellPart shellPart = new ShellPart("shell", 2, 3, 5); EndurancePart endurancePart = new EndurancePart("hp", 2, 3, 6); Vanguard vanguardVehicle = new Vanguard("moodle", 4, 5, 100, 100, 100, new VehicleAssembler()); vanguardVehicle.AddArsenalPart(arsenalPart); vanguardVehicle.AddShellPart(shellPart); vanguardVehicle.AddEndurancePart(endurancePart); string expected = vanguardVehicle.ToString(); string actual = "Vanguard - moodle\r\nTotal Weight: 8.500\r\nTotal Price: 13.555\r\nAttack: 120\r\nDefense: 105\r\nHitPoints: 106\r\nParts: model, shell, hp"; Assert.AreEqual(expected, actual); }
public void DoesTotalHitPointSumIsCorrest() { string model = "aaa"; double weight = 1; decimal price = 1; int attack = 1; int defense = 1; int hitpoint = 1; var assembler = new VehicleAssembler(); var revenger = new Revenger(model, weight, price, attack, defense, hitpoint, assembler); var endurance = new EndurancePart("aaa", 1, 1, 100); revenger.AddEndurancePart(endurance); Assert.AreEqual(101, revenger.TotalHitPoints); }
public void CheckAddingItemsAndModifiengProperties() { string model = "Rhino-CE"; double weight = 10; decimal price = 10m; int attack = 10; int defense = 10; int hitPoints = 10; IAssembler assembler = new VehicleAssembler(); BaseVehicle testVehicle = new Revenger(model, weight, price, attack, defense, hitPoints, assembler); IPart arsenalPart = new ArsenalPart("shel1", 1, 1, 2); testVehicle.AddArsenalPart(arsenalPart); Assert.That(testVehicle.Parts.Count() == 1 && testVehicle.Parts.Contains(arsenalPart), "Arsenal part not added properly"); IPart shellPart = new ShellPart("shel1", 1, 1, 2); testVehicle.AddShellPart(shellPart); Assert.That(testVehicle.Parts.Count() == 2 && testVehicle.Parts.Contains(shellPart), "Shell part not added properly"); IPart endurancePart = new EndurancePart("shel1", 1, 1, 2); testVehicle.AddEndurancePart(endurancePart); Assert.That(testVehicle.Parts.Count() == 3 && testVehicle.Parts.Contains(endurancePart), "Endurance part not added properly"); double TotalWeightExpected = 3 + 10; Assert.AreEqual(TotalWeightExpected, testVehicle.TotalWeight); decimal TotalPriceExpected = 3 + 10; Assert.AreEqual(TotalPriceExpected, testVehicle.TotalPrice); long TotalAttackExpected = 10 + 2; Assert.AreEqual(TotalAttackExpected, testVehicle.TotalAttack); long TotalDefenseExpected = 10 + 2; Assert.AreEqual(TotalDefenseExpected, testVehicle.TotalDefense); long TotalHitPointsExpected = 10 + 2; Assert.AreEqual(TotalHitPointsExpected, testVehicle.TotalHitPoints); }
public void AddEndurancePartShouldAddThePartToOrderedParts() { //Arrange IPart part = new EndurancePart("part", 10, 10, 10); IAssembler assembler = new VehicleAssembler(); IVehicle vehicle = new Revenger("revenger", 10, 10, 10, 10, 10, assembler); //Action vehicle.AddEndurancePart(part); FieldInfo orderedPartsField = vehicle.GetType().BaseType.GetField("orderedParts", BindingFlags.NonPublic | BindingFlags.Instance); List <string> orderedParts = (List <string>)orderedPartsField.GetValue(vehicle); //Assert Assert.AreEqual(true, orderedParts[0] == part.Model); }
public void TestAddPartCorrectly() { IAssembler assembler = new VehicleAssembler(); Revenger revenger = new Revenger("Test", 100, 100, 100, 100, 100, assembler); ArsenalPart arsenalPart = new ArsenalPart("Arsenal", 23, 50, 5); EndurancePart endurancePart = new EndurancePart("Endurance", 23, 50, 5); ShellPart shellPart = new ShellPart("Shell", 23, 50, 5); Assert.DoesNotThrow(() => revenger.AddArsenalPart(arsenalPart)); Assert.DoesNotThrow(() => revenger.AddEndurancePart(endurancePart)); Assert.DoesNotThrow(() => revenger.AddShellPart(shellPart)); string actualResult = revenger.ToString(); string expectedResult = "Revenger - Test\r\nTotal Weight: 169.000\r\nTotal Price: 250.000\r\nAttack: 105\r\nDefense: 105\r\nHitPoints: 105\r\nParts: Arsenal, Endurance, Shell"; Assert.AreEqual(actualResult, expectedResult); }
public void ValidateAddArsenal() { IVehicle vehicle = new Vanguard("SA-203", 100.00, 300m, 1000, 450, 2000, new VehicleAssembler()); IPart arsenalPart = new ArsenalPart("Cannon-KA2", 300, 500, 450); IPart shellPart = new ShellPart("Shields-PI1", 200, 1000, 750); IPart endurancePart = new EndurancePart("endurance", 200, 1000, 750); vehicle.AddArsenalPart(arsenalPart); vehicle.AddShellPart(shellPart); vehicle.AddEndurancePart(endurancePart); Assert.That(vehicle.Parts.ToList().Count == 3); }
public void PartsPropertyShouldReturnAllElements() { BasePart[] parts = new BasePart[3]; parts[0] = new ArsenalPart("ModelA", 150, 500, 100); parts[1] = new ShellPart("ModelS", 250, 250, 100); parts[2] = new EndurancePart("ModelE", 200, 250, 100); vehicle.AddArsenalPart(parts[0]); vehicle.AddShellPart(parts[1]); vehicle.AddEndurancePart(parts[2]); int index = 0; foreach (var part in vehicle.Parts) { Assert.AreSame(part, parts[index++]); } }
public void PartsPropertyShouldReturnCollectionWithAllTypesOfParts() { var part1 = new EndurancePart("model", 10, 10, 10); var part2 = new ShellPart("model", 10, 10, 10); var part3 = new ArsenalPart("model", 10, 10, 10); IAssembler assembler = new VehicleAssembler(); assembler.AddEndurancePart(part1); assembler.AddShellPart(part2); assembler.AddArsenalPart(part3); IVehicle v = new Revenger("revenger", 10, 10, 10, 10, 10, assembler); var expectedCount = 3; var actualCount = v.Parts.Count(); Assert.AreEqual(expectedCount, actualCount); }
public void TestVanguard() { Vanguard vehicle = new Vanguard("Kolio", 80, 3M, 1, 1, 1, new VehicleAssembler()); ArsenalPart arsenalPart = new ArsenalPart("Ars1", 10, 3M, 10); EndurancePart endurancePart = new EndurancePart("End1", 10, 3M, 10); ShellPart shellPart = new ShellPart("Shell1", 10, 3M, 10); vehicle.AddArsenalPart(arsenalPart); vehicle.AddEndurancePart(endurancePart); vehicle.AddShellPart(shellPart); int expectedAttack = 11; int expectedEndurance = 11; int expectedDefense = 11; int expectedWeight = 110; decimal totalPrice = 12M; List <IPart> orderedParts = new List <IPart>(); orderedParts.Add(arsenalPart); orderedParts.Add(shellPart); orderedParts.Add(endurancePart); StringBuilder result = new StringBuilder(); result.AppendLine($"{vehicle.GetType().Name} - {vehicle.Model}"); result.AppendLine($"Total Weight: {vehicle.TotalWeight:F3}"); result.AppendLine($"Total Price: {vehicle.TotalPrice:F3}"); result.AppendLine($"Attack: {vehicle.TotalAttack}"); result.AppendLine($"Defense: {vehicle.TotalDefense}"); result.AppendLine($"HitPoints: {vehicle.TotalHitPoints}"); result.Append("Parts: "); result.Append("Ars1, End1, Shell1"); string expectedToString = result.ToString(); string actualToString = vehicle.ToString(); Assert.AreEqual(expectedToString, actualToString); Assert.AreEqual(expectedAttack, vehicle.TotalAttack); Assert.AreEqual(expectedEndurance, vehicle.TotalHitPoints); Assert.AreEqual(expectedDefense, vehicle.TotalDefense); Assert.AreEqual(expectedWeight, vehicle.TotalWeight); Assert.AreEqual(totalPrice, vehicle.TotalPrice); }
public void ValidateTotalPropertie_AddPartsMethods_PartsProperty() { var revenger = new Revenger("Reven", 6d, 6m, 6, 6, 6, new VehicleAssembler()); var arsenalPart = new ArsenalPart("Ars", 6d, 6m, 6); revenger.AddArsenalPart(arsenalPart); Assert.AreEqual(revenger.TotalAttack, 12, $"TotalAttack property returns invalid result"); Assert.AreEqual(revenger.TotalDefense, 6, $"TotalDefense property returns invalid result"); Assert.AreEqual(revenger.TotalHitPoints, 6, $"TotalHitPoints property returns invalid result"); Assert.AreEqual(revenger.TotalPrice, 12, $"TotalPrice property returns invalid result"); Assert.AreEqual(revenger.TotalWeight, 12, $"TotalWeight property returns invalid result"); var endurancePart = new EndurancePart("End", 6d, 6m, 6); revenger.AddEndurancePart(endurancePart); Assert.AreEqual(revenger.TotalAttack, 12, $"TotalAttack property returns invalid result"); Assert.AreEqual(revenger.TotalDefense, 6, $"TotalDefense property returns invalid result"); Assert.AreEqual(revenger.TotalHitPoints, 12, $"TotalHitPoints property returns invalid result"); Assert.AreEqual(revenger.TotalPrice, 18, $"TotalPrice property returns invalid result"); Assert.AreEqual(revenger.TotalWeight, 18, $"TotalWeight property returns invalid result"); var shellPart = new ShellPart("End", 6d, 6m, 6); revenger.AddShellPart(shellPart); Assert.AreEqual(revenger.TotalAttack, 12, $"TotalAttack property returns invalid result"); Assert.AreEqual(revenger.TotalDefense, 12, $"TotalDefense property returns invalid result"); Assert.AreEqual(revenger.TotalHitPoints, 12, $"TotalHitPoints property returns invalid result"); Assert.AreEqual(revenger.TotalPrice, 24, $"TotalPrice property returns invalid result"); Assert.AreEqual(revenger.TotalWeight, 24, $"TotalWeight property returns invalid result"); var actualParts = revenger.Parts; var expectedParts = new List <IPart>() { arsenalPart, shellPart, endurancePart }; Assert.AreEqual(actualParts, expectedParts, $"Parts property returns invalid result"); }
public void CheckIfReturnCorrectResultAfterBattle() { var assembler = new VehicleAssembler(); var tank = new Vanguard("SA - 203", 100, 300, 1000, 450, 2000, assembler); var tank2 = new Revenger("AKU", 1000, 1000, 1000, 1000, 1000, assembler); var part1 = new ArsenalPart("Cannon - KA2", 300, 500, 450); var part2 = new ShellPart("Shields - PI1", 200, 1000, 750); var part3 = new EndurancePart("Shields - PI1", 200, 1000, 750); tank.AddArsenalPart(part1); tank2.AddShellPart(part2); tank2.AddEndurancePart(part3); var expectedResult = tank2.ToString(); var actualResult = "Revenger - AKU\r\nTotal Weight: 1700.000\r\nTotal Price: 3500.000\r\nAttack: 1450\r\nDefense: 1750\r\nHitPoints: 1750\r\nParts: Shields - PI1, Shields - PI1"; Assert.AreEqual(expectedResult, actualResult); }
public void ValidateToString() { IVehicle vehicle = new Vanguard("SA-203", 100.00, 300m, 1000, 450, 2000, new VehicleAssembler()); IPart arsenalPart = new ArsenalPart("Cannon-KA2", 300, 500, 450); IPart shellPart = new ShellPart("Shields-PI1", 200, 1000, 750); IPart endurancePart = new EndurancePart("endurance", 200, 1000, 750); vehicle.AddArsenalPart(arsenalPart); vehicle.AddShellPart(shellPart); vehicle.AddEndurancePart(endurancePart); string actualResult = vehicle.ToString(); string expectedResult = "Vanguard - SA-203\r\nTotal Weight: 800.000\r\nTotal Price: 2800.000\r\nAttack: 1450\r\nDefense: 1200\r\nHitPoints: 2750\r\nParts: Cannon-KA2, Shields-PI1, endurance"; Assert.AreEqual(actualResult, expectedResult); }
public void TestToString() { // Test if ToString() returns all the correct result var vehicle = new Vanguard("SA-203", 100, 300, 1000, 450, 2000, new VehicleAssembler()); var arsenalPart = new ArsenalPart("Arsenal", 100, 300, 1000); var shellPart = new ShellPart("Shell", 100, 300, 1000); var shellTwoPart = new ShellPart("Shell2", 100, 300, 1000); var endurancePart = new EndurancePart("Endurance", 100, 300, 1000); vehicle.AddArsenalPart(arsenalPart); vehicle.AddShellPart(shellPart); vehicle.AddShellPart(shellTwoPart); vehicle.AddEndurancePart(endurancePart); var expectedResult = "Vanguard - SA-203\r\nTotal Weight: 500.000\r\nTotal Price: 1500.000\r\nAttack: 2000\r\nDefense: 2450\r\nHitPoints: 3000\r\nParts: Arsenal, Shell, Shell2, Endurance"; var actualResult = vehicle.ToString(); Assert.AreEqual(expectedResult, actualResult); }
public void TestRevenger() { Revenger vehicle = new Revenger("Kolio", 80, 3M, 1, 1, 1, new VehicleAssembler()); ArsenalPart arsenalPart = new ArsenalPart("Ars1", 10, 3M, 10); EndurancePart endurancePart = new EndurancePart("End1", 10, 3M, 10); ShellPart shellPart = new ShellPart("Shell1", 10, 3M, 10); vehicle.AddArsenalPart(arsenalPart); vehicle.AddEndurancePart(endurancePart); vehicle.AddShellPart(shellPart); int expectedAttack = 11; int expectedEndurance = 11; int expectedDefense = 11; int expectedWeight = 110; decimal totalPrice = 12M; Assert.AreEqual(expectedAttack, vehicle.TotalAttack); Assert.AreEqual(expectedEndurance, vehicle.TotalHitPoints); Assert.AreEqual(expectedDefense, vehicle.TotalDefense); Assert.AreEqual(expectedWeight, vehicle.TotalWeight); Assert.AreEqual(totalPrice, vehicle.TotalPrice); }
public void ValidateReturnString() { var vehicle = new Revenger("Model1", 100, 100, 10, 10, 10, new VehicleAssembler()); StringBuilder result = new StringBuilder(); result.AppendLine($"Revenger - Model1"); result.AppendLine($"Total Weight: {100:F3}"); result.AppendLine($"Total Price: {100:F3}"); result.AppendLine($"Attack: {10}"); result.AppendLine($"Defense: {10}"); result.AppendLine($"HitPoints: {10}"); result.Append("Parts: None"); Assert.That(vehicle.ToString(), Is.EqualTo(result.ToString())); var attackPart = new ArsenalPart("ArsenalModel", 1.5, 2.5m, 10); var shellPart = new ShellPart("ShellModel", 1.5, 2.5m, 15); var endurancePart = new EndurancePart("EnduranceModel", 1.5, 2.5m, 20); vehicle.AddEndurancePart(endurancePart); vehicle.AddArsenalPart(attackPart); vehicle.AddShellPart(shellPart); result.Clear(); result.AppendLine($"Revenger - Model1"); result.AppendLine($"Total Weight: {104.5:F3}"); result.AppendLine($"Total Price: {107.5:F3}"); result.AppendLine($"Attack: {20}"); result.AppendLine($"Defense: {25}"); result.AppendLine($"HitPoints: {30}"); result.Append("Parts: EnduranceModel, ArsenalModel, ShellModel"); Assert.That(vehicle.ToString(), Is.EqualTo(result.ToString())); }