/// <summary> /// Initializes the instance by storing the given information. /// </summary> /// <param name="context">Context information for the test case</param> /// <param name="testElement">The test element of the test that this event is for.</param> /// <param name="tcmInformation"> /// Information used to obtain further data about the test from the Test Case Management (TCM) server, /// or null if the test did not originate from TCM. /// </param> /// <param name="failureType">The type of failure which has occured.</param> public TestCaseFailedEventArgs( DataCollectionContext context, TestCase testElement, //TcmInformation tcmInformation, TestCaseFailureType failureType) : base(context, testElement) { // NOTE: ONLY USE FOR UNIT TESTING! // This overload is only here for 3rd parties to use for unit testing // their data collectors. Internally we should not be passing the test element // around in the events as this is extra information that needs to be seralized // and the Execution Plugin Manager will fill this in for us before the event // is sent to the data collector when running in a production environment. FailureType = failureType; }
/// <summary> /// Initializes a new instance of the <see cref="TestCaseFailedEventArgs"/> class. /// </summary> /// <param name="context"> /// Context information for the test case /// </param> /// <param name="testCaseId"> /// The test case ID /// </param> /// <param name="testCaseName"> /// The test case name /// </param> /// <param name="isChildTestCase"> /// True if this is a child test case, false if this is a top-level test case /// </param> /// <param name="failureType"> /// The type of failure which has occurred. /// </param> internal TestCaseFailedEventArgs( DataCollectionContext context, Guid testCaseId, string testCaseName, bool isChildTestCase, TestCaseFailureType failureType) : base(context, testCaseId, testCaseName, isChildTestCase) { Debug.Assert(context.HasTestCase, "Context is not for a test case"); if (failureType < TestCaseFailureType.None || failureType > TestCaseFailureType.Other) { throw new ArgumentOutOfRangeException(nameof(failureType)); } this.FailureType = failureType; }
/// <summary> /// Initializes a new instance of the <see cref="FileTransferInformation"/> class. /// </summary> /// <param name="context"> /// The context in which the file is being sent. Cannot be null. /// </param> /// <param name="path"> /// The path to the file on the local file system /// </param> /// <param name="deleteFile"> /// True to automatically have the file removed after sending it. /// </param> public FileTransferInformation(DataCollectionContext context, string path, bool deleteFile) : base(context) { // EqtAssert.StringNotNullOrEmpty(path, "path"); // Expand environment variables in the path path = Environment.ExpandEnvironmentVariables(path); // Make sure the file exists. if (!File.Exists(path)) { throw new FileNotFoundException(string.Format(Resources.Resources.Common_FileNotExist, new object[] { path }), path); } // Make sure the path we have is a full path (not relative). this.Path = System.IO.Path.GetFullPath(path); this.PerformCleanup = deleteFile; }
public FileTransferInformation(DataCollectionContext context, string path, bool deleteFile, IFileHelper fileHelper) : base(context) { this.fileHelper = fileHelper; // Expand environment variables in the path path = Environment.ExpandEnvironmentVariables(path); // Make sure the file exists. if (!this.fileHelper.Exists(path)) { throw new FileNotFoundException(string.Format(Resources.Resources.Common_FileNotExist, new object[] { path }), path); } // Make sure the path we have is a full path (not relative). this.Path = this.fileHelper.GetFullPath(path); this.PerformCleanup = deleteFile; }
/// <summary> /// Initializes a new instance of the <see cref="TestCaseEventArgs"/> class. /// </summary> /// <param name="context"> /// Context information for the test case /// </param> /// <param name="testElement"> /// The test element of the test that this event is for. /// </param> protected TestCaseEventArgs( DataCollectionContext context, TestCase testElement) : this(context, Guid.Empty, null, false) { // NOTE: ONLY USE FOR UNIT TESTING! // This overload is only here for 3rd parties to use for unit testing // their data collectors. Internally we should not be passing the test element // around in the events as this is extra information that needs to be seralized // and the Execution Plugin Manager will fill this in for us before the event // is sent to the data collector when running in a production environment. // todo // EqtAssert.ParameterNotNull(testElement, "testElement"); this.TestElement = testElement; this.TestCaseId = testElement.Id; this.TestCaseName = testElement.DisplayName; // IsChildTestCase = testElement != null && // !testElement.ParentExecId.Equals(TestExecId.Empty); }
/// <summary> /// Initializes with the with required information for sending the contents of a stream. /// </summary> /// <param name="context">The context in which the file is being sent. Cannot be null.</param> /// <param name="stream">Stream to send.</param> /// <param name="fileName">File name to use for the data on the client.</param> /// <param name="closeStream">True to automatically have the stream closed when sending of the contents has completed.</param> public StreamTransferInformation(DataCollectionContext context, Stream stream, string fileName, bool closeStream) : base(context) { //todo //EqtAssert.ParameterNotNull(stream, "stream"); // Make sure the trimmed filename is not empty. if ((fileName == null) || (fileName = fileName.Trim()).Length == 0) { throw new ArgumentException(Resources.Resources.Common_CannotBeNullOrEmpty, "fileName"); } // Make sure the filename provided is not a reserved filename. if (FileHelper.IsReservedFileName(fileName)) { throw new ArgumentException(string.Format(Resources.Resources.DataCollectionSink_ReservedFilenameUsed, new object[] { fileName }), "fileName"); } // Make sure just the filename was provided. string invalidCharacters; if (!FileHelper.IsValidFileName(fileName, out invalidCharacters)) { throw new ArgumentException(string.Format(Resources.Resources.DataCollectionSink_InvalidFileNameCharacters, new object[] { fileName, invalidCharacters }), "fileName"); } // If we can not read the stream, throw. if (!stream.CanRead) { throw new InvalidOperationException(Resources.Resources.DataCollectionSink_CanNotReadStream); } Stream = stream; FileName = fileName; PerformCleanup = closeStream; }
/// <summary> /// Initializes a new instance of the <see cref="TestHostLaunchedEventArgs"/> class. /// </summary> /// <param name="context"> /// Data collection context /// </param> /// <param name="processId"> /// Process id of test host /// </param> public TestHostLaunchedEventArgs(DataCollectionContext context, int processId) : base(context) { this.processId = processId; }
/// <summary> /// Updates the data collection context stored by this instance. /// </summary> /// <param name="context">Context to update with.</param> /// <remarks> /// Generally the data collection context is known in advance, however there /// are cases around custom notifications where it is not necessarily known /// until the event is being sent. This is used for updating the context when /// sending the event. /// </remarks> internal void UpdateDataCollectionContext(DataCollectionContext context) { Debug.Assert(context != null, "'context' cannot be null."); Context = context; }
/// <summary> /// Initializes the instance by storing the given information /// </summary> /// <param name="context">Context information for the event</param> protected DataCollectionEventArgs(DataCollectionContext context) { Context = context; }
/// <summary> /// Initializes for sending a custom notification against the provided data collection context. /// </summary> /// <param name="context">Data Collection Context that the event is being sent against.</param> /// <param name="targetedUri">Uri of the targetd collector</param> internal CustomNotificationEventArgs(DataCollectionContext context, Uri targetDataCollectorUri) : base(context, targetDataCollectorUri) { this.NotificationIdentifier = Guid.NewGuid(); }
/// <summary> /// Initializes a new instance of the <see cref="SessionStartEventArgs"/> class. /// </summary> /// <param name="context"> /// Context information for the session /// </param> public SessionStartEventArgs(DataCollectionContext context, IDictionary <string, object> properties) : base(context) { this.Properties = properties; Debug.Assert(!context.HasTestCase, "Session event has test a case context"); }
/// <summary> /// Initializes the instance by storing the given information /// </summary> /// <param name="context">Context information for the test case</param> internal FlushDataEventArgs(DataCollectionContext context) : base(context) { }
/// <summary> /// Sends custom data from the collector /// </summary> /// <param name="context">Context under which the data collection is happening</param> /// <param name="data">Custom data to be sent</param> /// <remarks> /// When a Data Collector invokes this method, Client would get called on OnCollectionException( ) with a CollectionExceptionMessageEventArgs. /// </remarks> public virtual void SendData(DataCollectionContext context, CustomCollectorData data) { // Default no-op. }
/// <summary> /// Sends a file to up-stream components. /// </summary> /// <param name="context">The context in which the file is being sent. Cannot be null.</param> /// <param name="path">the path to the file on the local file system</param> /// <param name="deleteFile">True to automatically have the file removed after sending it.</param> public void SendFileAsync(DataCollectionContext context, string path, bool deleteFile) { this.SendFileAsync(context, path, string.Empty, deleteFile); }
/// <summary> /// Initializes the instance by storing the given information /// </summary> /// <param name="context">Context information for the event</param> protected DataCollectionEventArgs(DataCollectionContext context) : this(context, null) { }
/// <summary> /// Initializes a new instance of the <see cref="FileTransferInformation"/> class. /// </summary> /// <param name="context"> /// The context in which the file is being sent. Cannot be null. /// </param> /// <param name="path"> /// The path to the file on the local file system /// </param> /// <param name="deleteFile"> /// True to automatically have the file removed after sending it. /// </param> public FileTransferInformation(DataCollectionContext context, string path, bool deleteFile) : this(context, path, deleteFile, new TestPlatform.Utilities.Helpers.FileHelper()) { }
/// <summary> /// Logs an error message for an exception. /// </summary> /// <param name="context">The context in which the message is being sent.</param> /// <param name="exception">The exception. Cannot be null.</param> /// <remarks> /// When a Data Collector invokes this method, Client would get called on OnCollectionError( ) with a CollectionErrorMessageEventArgs. /// </remarks> public void LogError(DataCollectionContext context, Exception exception) { LogError(context, string.Empty, exception); }
/// <summary> /// Logs an error message for an exception. /// </summary> /// <param name="context">The context in which the message is being sent.</param> /// <param name="text">Text explaining the exception. Cannot be null.</param> /// <param name="exception">The exception. Cannot be null.</param> /// <remarks> /// When a Data Collector invokes this method, Client would get called on OnCollectionError( ) with a CollectionErrorMessageEventArgs. /// </remarks> public abstract void LogError(DataCollectionContext context, string text, Exception exception);
/// <summary> /// Initializes a new instance of the <see cref="SessionEndEventArgs"/> class. /// </summary> /// <param name="context"> /// Context information for the session /// </param> public SessionEndEventArgs(DataCollectionContext context) : base(context) { Debug.Assert(!context.HasTestCase, "Session event has test a case context"); }
/// <summary> /// Logs a warning. /// </summary> /// <param name="context">The context in which the message is being sent.</param> /// <param name="text">The warning text. Cannot be null.</param> /// <remarks> /// When a Data Collector invokes this method, Client would get called on OnCollectionWarning( ) with a CollectionWarningMessageEventArgs. /// </remarks> public abstract void LogWarning(DataCollectionContext context, string text);
/// <summary> /// Initializes for sending a custom notification against the provided data collection context. /// </summary> /// <param name="context">Data Collection Context that the event is being sent against.</param> internal CustomNotificationEventArgs(DataCollectionContext context) : this(context, null) { }
/// <summary> /// Logs and given exception to the client. /// </summary> /// <param name="context"></param> /// <param name="ex">The exception to be logged</param> /// <param name="level"> Is the exception at warning level or error level.</param> /// <remarks> /// When a Data Collector invokes this method, Client would get called on OnCollectionException( ) with a CollectionExceptionMessageEventArgs. /// </remarks> public virtual void LogException(DataCollectionContext context, Exception ex, DataCollectorMessageLevel level) { }
/// <summary> /// Initializes with the DataCollectionContext /// </summary> public DataCollectionEnvironmentContext(DataCollectionContext sessionDataCollectionContext) { SessionDataCollectionContext = sessionDataCollectionContext; }
/// <summary> /// Sends a stream to up-stream components. /// </summary> /// <param name="context">The context in which the stream is being sent. Cannot be null.</param> /// <param name="stream">Stream to send.</param> /// <param name="fileName">File name to use for the data on the client.</param> /// <param name="closeStream">True to automatically have the stream closed when sending of the contents has completed.</param> public void SendStreamAsync(DataCollectionContext context, Stream stream, string fileName, bool closeStream) { SendStreamAsync(context, stream, fileName, String.Empty, closeStream); }