public void A100_GetListForRegionKey()
        {
            List <Country> countries = countriesRepository.GetListForRegionKey(Region2.PrimaryKey);

            Assert.AreEqual(expectedRegion2Records, countries.Count);
            Assert.AreEqual(Country2.PrimaryKey, countries[0].PrimaryKey);
        }
예제 #2
0
        /// <summary>The validations for a delete.</summary>
        /// <param name="primaryKey">The primary key of the region to delete.</param>
        /// <exception cref="RegionNotFoundException">
        /// Happens when the primary key can not be found.
        /// </exception>
        /// <exception cref="RegionInUseException">Happens when the regions is used in a country.</exception>
        public override void ValidateDelete(string primaryKey)
        {
            Region region = regionsRepository.GetById(primaryKey);

            if (region == null)
            {
                throw new RegionNotFoundException(RegionNotFoundException.RegionKeyNotFoundMsg, primaryKey);
            }

            List <Country> countries = countriesRespository.GetListForRegionKey(primaryKey);

            if (countries.Count > 0)
            {
                throw new RegionInUseException(RegionInUseException.RegionInUseCanNotBeDeletedCountryMsg);
            }
        }