예제 #1
0
        private bool CanIAdd(Object anObject)
        {
            SchoolVanValidator validator = new SchoolVanValidator();

            if (Exists(anObject))
            {
                throw new SchoolVanAlreadyExistsException("El id ingresado de camioneta ya existe");
            }
            return(validator.IsValid(anObject) && !Exists(anObject));
        }
예제 #2
0
        public void OutOfBandsSchoolVanCapacity()
        {
            int       aId      = 1;
            int       capacity = 2000;
            SchoolVan aVan     = new SchoolVan();

            aVan.Id       = aId;
            aVan.Capacity = capacity;
            SchoolVanValidator validator = new SchoolVanValidator();

            Assert.IsFalse(validator.IsValid(aVan));
        }
예제 #3
0
        public void ValidSchoolVanCapacity()
        {
            int       aId      = 1;
            int       capacity = 5;
            SchoolVan aVan     = new SchoolVan();

            aVan.Id       = aId;
            aVan.Capacity = capacity;
            SchoolVanValidator validator = new SchoolVanValidator();

            Assert.IsTrue(validator.IsValid(aVan));
        }
예제 #4
0
        private bool ModifyValidation(Object anObject, Object anotherObject)
        {
            SchoolVanValidator validator = new SchoolVanValidator();
            bool domainValidation        = validator.IsValid(anotherObject);
            bool nonExists = !Exists(anotherObject);
            bool sameId    = anObject.Equals(anotherObject);

            if (!(nonExists || sameId))
            {
                throw new SchoolVanAlreadyExistsException("El id ingresado de camioneta ya existe");
            }
            return(domainValidation && (nonExists || sameId));
        }
예제 #5
0
        public void InvalidFuelConsumptionSchoolVan()
        {
            int       aId             = 1;
            int       capacity        = 10;
            int       fuelConsumption = 0;
            SchoolVan aVan            = new SchoolVan();

            aVan.Id              = aId;
            aVan.Capacity        = capacity;
            aVan.FuelConsumption = fuelConsumption;
            SchoolVanValidator validator = new SchoolVanValidator();

            Assert.IsFalse(validator.IsValid(aVan));
        }
예제 #6
0
        public void Remove(Object anObject)
        {
            bool      canIDelete = false;
            SchoolVan toDelete   = anObject as SchoolVan;

            try
            {
                SchoolVanValidator validator = new SchoolVanValidator();
                if (validator.IsValid(toDelete))
                {
                    canIDelete = true;
                }
            }
            catch (Exception)
            {
                throw new InvalidValueException("No se puede eliminar un objeto que no sea del tipo SchoolVan");
            }
            if (canIDelete)
            {
                SchoolVanAccess context = new SchoolVanAccess();
                context.Remove(toDelete);
            }
        }