Exemple #1
0
        /// <summary>
        /// Generates a random VIN
        /// </summary>
        /// <param name="allowForOldModel">
        /// Allow random to produce model years back to 1980
        /// </param>
        /// <returns></returns>
        public static Vin GetRandomVin(bool allowForOldModel = false)
        {
            var wmiAndName = WorldManufacturerId.GetRandomManufacturerId();
            var wmiOut = wmiAndName.Item1;

            //when this is a digit it will allow for a much older make back to 1980
            var yearBaseDeterminer = allowForOldModel && Etx.TryAboveOrAt(66, Etx.Dice.OneHundred)
                ? DF_DIGIT
                : GetRandomVinChar();

            var vds = new VehicleDescription
            {
                Four = GetRandomVinChar(),
                Five = GetRandomVinChar(),
                Six = GetRandomVinChar(),
                Seven = yearBaseDeterminer,
                Eight = GetRandomVinChar()
            };

            var vis = VehicleIdSection.GetVehicleIdSection(vds);

            var vin = new Vin {Wmi = wmiOut, Vds = vds, Vis = vis};

            if (!string.IsNullOrWhiteSpace(wmiAndName.Item2))
                vin.Description = wmiAndName.Item2;

            return vin;
        }
Exemple #2
0
        public static VehicleIdSection GetVehicleIdSection(VehicleDescription vds)
        {
            const int AMENDED_BASE_YEAR = 2010;

            var pick = Etx.IntNumber(0, DateTime.Today.Year - AMENDED_BASE_YEAR);

            if (char.IsNumber(vds.Seven.GetValueOrDefault()))
                pick = Etx.IntNumber(0, Vin.YearIdx.Length-1);

            var vis = new VehicleIdSection
            {
                ModelYear = Vin.YearIdx[pick],
                PlantCode = Vin.GetRandomVinChar(),
                SequentialNumber = Etx.Chars(0x30, 0x39, 6)
            };

            return vis;
        }