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!");
            }
        }
Пример #2
0
        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 ShouldAddArsenalPart()
        {
            IPart arsenalPart = new ArsenalPart(partModel, partWeight, partPrice, attackMod);

            IVehicle vehicle = new Vanguard(model, weight, price, attack, defense, hitPoints, assembler);

            vehicle.AddArsenalPart(arsenalPart);
            Assert.That(vehicle.TotalAttack > 50);
        }
Пример #4
0
        public void CheckPartsAddition()
        {
            IVehicle vehicle = new Vanguard("KillingMachine", 123, 3446m, 9000, 876, 56, new VehicleAssembler());

            vehicle.AddArsenalPart(new ArsenalPart("arsenalModel", 5.3, 20.45m, 32));
            vehicle.AddShellPart(new ShellPart("shellModel", 10, 2000m, 700));
            vehicle.AddEndurancePart(new EndurancePart("enduranceModel", 100, 700m, 30));

            Assert.That(vehicle.Parts.Count().Equals(3));
        }
Пример #5
0
        public void CheckToString()
        {
            IVehicle vehicle = new Vanguard("KillingMachine", 123, 3446m, 9000, 876, 56, new VehicleAssembler());

            vehicle.AddArsenalPart(new ArsenalPart("arsenalModel", 5.3, 20.45m, 32));
            vehicle.AddShellPart(new ShellPart("shellModel", 10, 2000m, 700));
            vehicle.AddEndurancePart(new EndurancePart("enduranceModel", 100, 700m, 30));

            var actual   = vehicle.ToString();
            var expected = "Vanguard - KillingMachine\r\nTotal Weight: 238.300\r\nTotal Price: 6166.450\r\nAttack: 9032\r\nDefense: 1576\r\nHitPoints: 86\r\nParts: arsenalModel, shellModel, enduranceModel";

            Assert.AreEqual(expected, actual);
        }
Пример #6
0
        public void CheckIfWeaponsAreAddedProperly()
        {
            IVehicle vehicle = new Vanguard(model, weight, price, attack, defense, hitPoints, assembler);

            vehicle.AddArsenalPart(new ArsenalPart("test1", 100, 100, 2));
            vehicle.AddEndurancePart(new EndurancePart("test2", 200, 200, 3));
            vehicle.AddShellPart(new ShellPart("test3", 100, 100, 4));

            string actualResult   = vehicle.ToString();
            string expectedResult = "Vanguard - SA-203\r\nTotal Weight: 500.000\r\nTotal Price: 700.000\r\nAttack: 1002\r\nDefense: 454\r\nHitPoints: 2003\r\nParts: test1, test2, test3";

            Assert.That(actualResult, Is.EqualTo(expectedResult));
        }
Пример #7
0
        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);
        }
Пример #8
0
        public void CheckIfReturnCorrectResult2()
        {
            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);

            tank.AddArsenalPart(part1);
            tank.AddShellPart(part2);

            var expectedResult = tank.ToString();
            var actualResult   = "Vanguard - SA - 203\r\nTotal Weight: 600.000\r\nTotal Price: 1800.000\r\nAttack: 1450\r\nDefense: 1200\r\nHitPoints: 2000\r\nParts: Cannon - KA2, Shields - PI1";

            Assert.AreEqual(expectedResult, actualResult);
        }
Пример #9
0
        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 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);
        }
Пример #11
0
        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);
        }
Пример #12
0
        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 TestMethods()
        {
            string     model     = "Gosho";
            double     weight    = 22.2;
            decimal    price     = 5;
            int        attack    = 3;
            int        defense   = 4;
            int        hitpoints = 2;
            IAssembler assembler = new VehicleAssembler();
            var        vanguard  = new Vanguard(model, weight, price, attack, defense, hitpoints, assembler);
            //checks if Parts is empty
            var expectedParts = vanguard.Parts.Count();
            var actualParts   = 0;

            Assert.AreEqual(expectedParts, actualParts);

            IPart arsenal   = new ArsenalPart("123", 33.2, 7, 250);
            IPart shell     = new ShellPart("123", 33.2, 7, 250);
            IPart endurance = new EndurancePart("123", 33.2, 7, 250);
            //checks toString() before adding vehicle parts
            var expectedBefore = vanguard.ToString();
            var actualBefore   = "Vanguard - Gosho\r\nTotal Weight: 22.200\r\nTotal Price: 5.000\r\nAttack: 3\r\nDefense: 4\r\nHitPoints: 2\r\nParts: None";

            Assert.AreEqual(expectedBefore, actualBefore);
            //checks toString() after adding vehicle parts
            vanguard.AddArsenalPart(arsenal);
            vanguard.AddShellPart(shell);
            vanguard.AddEndurancePart(endurance);

            var expectedAfter = vanguard.ToString();
            var actualAfter   = "Vanguard - Gosho\r\nTotal Weight: 121.800\r\nTotal Price: 26.000\r\nAttack: 253\r\nDefense: 254\r\nHitPoints: 252\r\nParts: 123, 123, 123";

            Assert.AreEqual(expectedAfter, actualAfter);
            //checks Parts list count after adding vehicle parts
            Assert.AreEqual(vanguard.Parts.Count(), 3);
        }