/// <summary>
        /// Sends text to message sink.
        /// </summary>
        /// <param name="context">
        /// The context.
        /// </param>
        /// <param name="text">
        /// The text.
        /// </param>
        /// <param name="level">
        /// The level.
        /// </param>
        /// <exception cref="InvalidOperationException">Throws InvalidOperationException.
        /// </exception>
        private void SendTextMessage(DataCollectionContext context, string text, TestMessageLevel level)
        {
            ValidateArg.NotNull(context, "context");
            ValidateArg.NotNull(text, "text");

            Debug.Assert(
                level >= TestMessageLevel.Informational && level <= TestMessageLevel.Error,
                "Invalid level: " + level);

            // Make sure the data collection context is not a derived data collection context.  This
            // is done to safeguard from 3rd parties creating their own data collection contexts.
            if (context.GetType() != typeof(DataCollectionContext))
            {
                throw new InvalidOperationException(Resources.Resources.WrongDataCollectionContextType);
            }

            var args = new DataCollectionMessageEventArgs(level, text);

            args.Uri          = this.dataCollectorConfig.TypeUri;
            args.FriendlyName = this.dataCollectorConfig.FriendlyName;
            if (context.HasTestCase)
            {
                args.TestCaseId = context.TestExecId.Id;
            }

            this.sink.SendMessage(args);
        }
        /// <inheritdoc/>
        public override void LogError(DataCollectionContext context, string text, Exception exception)
        {
            ValidateArg.NotNull(context, "context");
            ValidateArg.NotNull(text, "text");
            ValidateArg.NotNull(exception, "exception");

            // Make sure the data collection context is not a derived data collection context.  This
            // is done to safeguard from 3rd parties creating their own data collection contexts.
            if (context.GetType() != typeof(DataCollectionContext))
            {
                throw new InvalidOperationException(Resources.Resources.WrongDataCollectionContextType);
            }

            if (EqtTrace.IsErrorEnabled)
            {
                EqtTrace.Error(
                    "Data collector '{0}' logged the following error:" + Environment.NewLine +
                    "Description:            {1}" + Environment.NewLine +
                    "Exception type:         {2}" + Environment.NewLine + "Exception message:      {3}"
                    + Environment.NewLine + "Exception stack trace:  {4}",
                    this.dataCollectorConfig.TypeUri,
                    text,
                    exception.GetType(),
                    exception.Message,
                    exception.StackTrace);
            }

            // Currently there is one type of DataCollectionMessage sent accross client for all message kind.
            // If required new type can be created for different message type.
            var message = string.Format(
                CultureInfo.CurrentCulture,
                Resources.Resources.ReportDataCollectorException,
                exception.GetType(),
                exception.Message,
                text);

            this.SendTextMessage(context, message, TestMessageLevel.Error);
        }