public void A100_GetListForManufacture()
        {
            List <Car> cars = carsRepository.GetListForManufacturerKey(Manufacturer1.PrimaryKey);

            Assert.AreEqual(numberOfCarsForManufacturer, cars.Count);
            Assert.AreEqual(Car1.PrimaryKey, cars[0].PrimaryKey);
        }
예제 #2
0
        /// <summary>Validations done to an entity for the passed primary key before it is deleted.</summary>
        /// <param name="primaryKey">The primary key of the entity to delete.</param>
        /// <exception cref="GTSport_DT.Manufacturers.ManufacturerNotFoundException">
        /// When the manufacturer can not be found to be deleted.
        /// </exception>
        /// <exception cref="GTSport_DT.Manufacturers.ManufacturerInUseException">
        /// When the manufacture is in use with a car record.
        /// </exception>
        public override void ValidateDelete(string primaryKey)
        {
            Manufacturer manufacturer = manufacturersRepository.GetById(primaryKey);

            if (manufacturer == null)
            {
                throw new ManufacturerNotFoundException(ManufacturerNotFoundException.ManufacturerKeyNotFoundMsg, primaryKey);
            }

            List <Car> cars = carsRepository.GetListForManufacturerKey(primaryKey);

            if (cars.Count > 0)
            {
                throw new ManufacturerInUseException(ManufacturerInUseException.ManufacturerInUseCanNotBeDeletedCarMsg);
            }
        }