コード例 #1
0
        /// <summary>
        /// Generates random test serviceability response.
        /// </summary>
        /// <param name="address">Location postal address</param>
        /// <returns>Array of serviceability results from cable providers</returns>
        private async Task <ServiceabilityResult[]> MockDetermineBusinessServiceabilityAsync(Address address)
        {
            await Task.Delay(1500);

            // Simulate random errors
            if (this._account.EnableTestError && RandomData.Chance(1, 100))
            {
                throw RandomData.NextError();
            }

            // Generate random results
            var resultCount = RandomData.NextInteger(0, 2);
            var results     = new List <ServiceabilityResult>();

            for (var index = 0; index < resultCount; index++)
            {
                var provider = RandomData.NextProvider();
                var result   = new ServiceabilityResult
                {
                    LocationId   = RandomData.NextInteger(99999).ToString(),
                    LocationType = RandomData.Pick <LocationType>(new LocationType[] {
                        LocationType.Unknown, LocationType.Residential, LocationType.Business
                    }),
                    ProviderId = provider.Id,
                    Provider   = provider.Name,
                    SiteStatus = RandomData.Pick <SiteStatus>(new SiteStatus[] {
                        SiteStatus.OnNet, SiteStatus.OffNet, SiteStatus.NearNet,
                        SiteStatus.SurveyRequired, SiteStatus.Proximity
                    })
                };
                results.Add(result);
            }

            return(results.ToArray());
        }