public void A010_SaveNewTest()
        {
            manufacturersRepository.SaveAndFlush(Manufacturer1);

            Manufacturer manufacturerCheck = manufacturersRepository.GetById(Manufacturer1.PrimaryKey);

            Assert.IsNotNull(manufacturerCheck);
            Assert.AreEqual(Manufacturer1.PrimaryKey, manufacturerCheck.PrimaryKey);
            Assert.AreEqual(Manufacturer1.Name, manufacturerCheck.Name);
            Assert.AreEqual(Manufacturer1.CountryKey, manufacturerCheck.CountryKey);
        }
Exemple #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);
            }
        }