Exemple #1
0
        public void cannot_set_15_doors()
        {
            IEnrollmentProvider enrollmentProvider = new DefaultEnrollmentProvider();
            IVehicleBuilder     builder            = new VehicleBuilder(enrollmentProvider);

            Negassert.mustFail(() => builder.setDoors(15));
        }
Exemple #2
0
        public void inMemoryVehicleStorage_must_be_empty_on_each_instance()
        {
            IVehicle vehicle, motoVehicle;

            SingleEnrollmentProvider        enrollmentProvider = new SingleEnrollmentProvider();
            IEqualityComparer <IEnrollment> equalityComparer   = new EnrollmentEqualityComparer();
            IVehicleBuilder vehicleBuilder = new VehicleBuilder(enrollmentProvider);
            IVehicleStorage vehicleStorage = new InMemoryVehicleStorage();

            vehicleBuilder.addWheel();
            vehicleBuilder.addWheel();
            vehicleBuilder.setDoors(0);
            vehicleBuilder.setEngine(40);
            motoVehicle = vehicleBuilder.build();

            Assert.AreEqual(0, vehicleStorage.Count);
            vehicleStorage.set(motoVehicle);
            Assert.AreEqual(1, vehicleStorage.Count);

            vehicle = vehicleStorage.get(enrollmentProvider.DefaultEnrollment);
            Assert.IsNotNull(vehicle);
            Assert.IsTrue(equalityComparer.Equals(enrollmentProvider.DefaultEnrollment, vehicle.Enrollment));

            vehicleStorage = new InMemoryVehicleStorage();
            Assert.AreEqual(0, vehicleStorage.Count);

            Negassert.mustFail(() =>
            {
                vehicle = vehicleStorage.get(enrollmentProvider.DefaultEnrollment);
            });
        }
Exemple #3
0
        public void WrongBuildRequests_01()
        {
            SingleEnrollmentProvider enrollmentProvider = new SingleEnrollmentProvider();
            IVehicleBuilder          builder            = new VehicleBuilder(enrollmentProvider);

            Negassert.mustFail(() => builder.removeWheel());
            builder.addWheel();
            builder.addWheel();
            builder.addWheel();
            builder.addWheel();

            Negassert.mustFail(() => builder.setDoors(-27));
            builder.setDoors(5);
            Negassert.mustFail(() => builder.setEngine(-40));
            Negassert.mustFail(() => builder.setEngine(0));
            builder.setEngine(100);
            Negassert.mustFail(() => builder.setColor((CarColor)27));

            IVehicle vehicle = builder.build();

            Negassert.mustFail(() => vehicle.Engine.stop());

            vehicle.Engine.start();
            Negassert.mustFail(() => vehicle.Engine.start());

            Negassert.mustFail(() => vehicle.setWheelsPressure(-1));
            Negassert.mustFail(() => vehicle.setWheelsPressure(0));
            Negassert.mustFail(() => vehicle.setWheelsPressure(0.99));
            Negassert.mustFail(() => vehicle.setWheelsPressure(5.01));
            vehicle.setWheelsPressure(2);
        }
Exemple #4
0
        public void engine_horse_power_can_not_be_negative()
        {
            IEnrollmentProvider enrollmentProvider = new DefaultEnrollmentProvider();
            IVehicleBuilder     builder            = new VehicleBuilder(enrollmentProvider);

            Negassert.mustFail(() => builder.setEngine(-70));
        }
Exemple #5
0
        public void cannot_create_vehicle_without_wheels()
        {
            IEnrollmentProvider enrollmentProvider = new DefaultEnrollmentProvider();
            IVehicleBuilder     builder            = new VehicleBuilder(enrollmentProvider);

            Negassert.mustFail(() =>
            {
                IVehicle vehicle = builder.build();
            });
        }
Exemple #6
0
        public void cannot_remove_wheel_if_there_are_not_wheels()
        {
            IEnrollmentProvider enrollmentProvider = new DefaultEnrollmentProvider();
            IVehicleBuilder     builder            = new VehicleBuilder(enrollmentProvider);

            builder.addWheel();
            builder.addWheel();
            builder.removeWheel();
            builder.removeWheel();

            Negassert.mustFail(() => builder.removeWheel());
        }
Exemple #7
0
        public void wheel_pressure_can_not_be_negative()
        {
            IEnrollmentProvider enrollmentProvider = new DefaultEnrollmentProvider();
            IVehicleBuilder     builder            = new VehicleBuilder(enrollmentProvider);

            builder.setColor(CarColor.Black);
            builder.setDoors(4);
            builder.setEngine(60);
            builder.addWheel();
            builder.addWheel();

            IVehicle vehicle = builder.build();

            Negassert.mustFail(() => vehicle.setWheelsPressure(-50));
        }
Exemple #8
0
        public void doors_must_be_between_0_and_6()
        {
            IEnrollmentProvider enrollmentProvider = new DefaultEnrollmentProvider();
            IVehicleBuilder     builder            = new VehicleBuilder(enrollmentProvider);

            for (int i = 0; i < MEDIUM; i++)
            {
                int doorsCount = this.random.Next(7, int.MaxValue);
                Negassert.mustFail(() => builder.setDoors(doorsCount));
            }

            for (int i = 0; i < MEDIUM; i++)
            {
                int doorsCount = this.random.Next(int.MinValue, 0);
                Negassert.mustFail(() => builder.setDoors(doorsCount));
            }
        }
Exemple #9
0
        public void Pressure_must_not_be_more_than_5()
        {
            IEnrollmentProvider enrollmentProvider = new DefaultEnrollmentProvider();
            IVehicleBuilder     builder            = new VehicleBuilder(enrollmentProvider);

            builder.setColor(CarColor.Black);
            builder.setDoors(4);
            builder.setEngine(60);
            builder.addWheel();
            builder.addWheel();

            IVehicle vehicle = builder.build();

            Negassert.mustFail(() => vehicle.setWheelsPressure(6));
            Negassert.mustFail(() => vehicle.setWheelsPressure(5.01));
            Negassert.mustFail(() => vehicle.setWheelsPressure(100));
            Negassert.mustFail(() => vehicle.setWheelsPressure(120.01));
        }
Exemple #10
0
        public void Pressure_must_not_be_less_than_1() // Posible conflicto con el test de JVBB
        {
            IEnrollmentProvider enrollmentProvider = new DefaultEnrollmentProvider();
            IVehicleBuilder     builder            = new VehicleBuilder(enrollmentProvider);

            builder.setColor(CarColor.Black);
            builder.setDoors(4);
            builder.setEngine(60);
            builder.addWheel();
            builder.addWheel();

            IVehicle vehicle = builder.build();

            Negassert.mustFail(() => vehicle.setWheelsPressure(0));
            Negassert.mustFail(() => vehicle.setWheelsPressure(0.99));
            Negassert.mustFail(() => vehicle.setWheelsPressure(-1));
            Negassert.mustFail(() => vehicle.setWheelsPressure(-10.5));
        }
Exemple #11
0
        public void cannot_openDoor_twice()
        {
            SingleEnrollmentProvider enrollmentProvider = new SingleEnrollmentProvider();
            IVehicleBuilder          builder            = new VehicleBuilder(enrollmentProvider);

            builder.addWheel();
            builder.addWheel();
            builder.addWheel();
            builder.addWheel();

            builder.setDoors(2);
            builder.setEngine(100);
            builder.setColor(CarColor.Red);

            IVehicle vehicle = builder.build();

            vehicle.Doors[0].open();
            Negassert.mustFail(() => vehicle.Doors[0].open());
        }