public void CheckIfValueIsSetCorectlly()
        {
            var vehicle = new Revenger("Model", 1.3, (decimal)4.1, 4, 5, 6, new VehicleAssembler());

            var properties = vehicle.GetType().GetProperties();

            Assert.That(vehicle.Model == "Model", Is.True);
            Assert.That(vehicle.Weight == 1.3, Is.True);
            Assert.That(vehicle.Price == (decimal)4.1, Is.True);
            Assert.That(vehicle.Attack == 4, Is.True);
            Assert.That(vehicle.Defense == 5, Is.True);
            Assert.That(vehicle.HitPoints == 6, Is.True);
        }
예제 #2
0
        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);
        }
예제 #3
0
        public void ToString_ShouldReturnTheCorrectString(string model,
                                                          double weight, decimal price, int attack, int defense, int hitPoints)
        {
            var vehicle = new Revenger(model, weight, price, attack, defense,
                                       hitPoints, new VehicleAssembler());

            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: None");

            var expected = result.ToString();
            var actual   = vehicle.ToString();

            Assert.AreEqual(expected, actual);
        }