/// <summary>
 ///     Initializes a new instance of the <see cref="UploadTocodeRR" /> class.
 /// </summary>
 /// <param name="oneTrueHost">
 ///     Uri to the root of the codeRR web. Example.
 ///     <code>http://yourWebServer/codeRR/</code>
 /// </param>
 /// <param name="apiKey">The API key.</param>
 /// <param name="sharedSecret">The shared secret.</param>
 /// <param name="config">parameters for tests</param>
 /// <exception cref="System.ArgumentNullException">apiKey</exception>
 internal UploadTocodeRR(Uri oneTrueHost, string apiKey, string sharedSecret, TestConfig config)
     : this(oneTrueHost, apiKey, sharedSecret)
 {
     _queueReportsAccessor    = config.QueueReportsAccessor;
     _throwExceptionsAccessor = config.ThrowExceptionsAccessor;
     _uploadFunc    = config.UploadFunc;
     _feedbackQueue = config.FeedbackQueue;
     _reportQueue   = config.ReportQueue;
 }
        /// <summary>
        ///     Initializes a new instance of the <see cref="UploadTocodeRR" /> class.
        /// </summary>
        /// <param name="oneTrueHost">
        ///     Uri to the root of the codeRR web. Example.
        ///     <code>http://yourWebServer/codeRR/</code>
        /// </param>
        /// <param name="apiKey">The API key.</param>
        /// <param name="sharedSecret">The shared secret.</param>
        /// <exception cref="System.ArgumentNullException">apiKey</exception>
        public UploadTocodeRR(Uri oneTrueHost, string apiKey, string sharedSecret)
        {
            if (string.IsNullOrEmpty(apiKey))
            {
                throw new ArgumentNullException("apiKey");
            }
            if (string.IsNullOrEmpty(sharedSecret))
            {
                throw new ArgumentNullException("sharedSecret");
            }

            if (!oneTrueHost.AbsolutePath.EndsWith("/"))
            {
                oneTrueHost = new Uri(oneTrueHost + "/");
            }

            if (oneTrueHost.AbsolutePath.Contains("/receiver/"))
            {
                throw new ArgumentException(
                          "The codeRR URI should not contain the reporting area '/receiver/', but should point at the site root.");
            }

            _reportUri    = new Uri(oneTrueHost, "receiver/report/" + apiKey + "/");
            _feedbackUri  = new Uri(oneTrueHost, "receiver/report/" + apiKey + "/feedback/");
            _apiKey       = apiKey;
            _sharedSecret = sharedSecret;

            _feedbackQueue = new UploadQueue <FeedbackDTO>(UploadFeedbackNow);
            _feedbackQueue.UploadFailed += OnUploadFailed;

            _reportQueue = new UploadQueue <ErrorReportDTO>(UploadReportNow);
            _reportQueue.UploadFailed += OnUploadFailed;

            _uploadFunc              = message => _client.SendAsync(message);
            _queueReportsAccessor    = () => Err.Configuration.QueueReports;
            _throwExceptionsAccessor = () => Err.Configuration.ThrowExceptions;
        }