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)); }
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)); }
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)); }
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)); }
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)); }
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); } }