/// <summary> /// Create a buildError event to compare to the one which was passed into the ProcessedBuildEvent method. /// </summary> /// <param name="fileInfo">FileInfo to create the comparison event with</param> /// <param name="errorCode">Errorcode to create the comparison event with c</param> /// <param name="helpKeyword">helpKeyword to create the comparison event with</param> /// <param name="message">message to create the comparison event with</param> /// <param name="service">LoggingService mock object which overrides ProcessBuildEvent and can provide a ProcessedBuildEvent (the event which would have been sent to the loggers)</param> /// <param name="subcategory">Subcategory to create the comparison event with</param> private void VerifyBuildErrorEventArgs(BuildEventFileInfo fileInfo, string errorCode, string helpKeyword, string message, ProcessBuildEventHelper service, string subcategory) { BuildErrorEventArgs buildEvent = new BuildErrorEventArgs ( subcategory, errorCode, fileInfo.File, fileInfo.Line, fileInfo.Column, fileInfo.EndLine, fileInfo.EndColumn, message, helpKeyword, "MSBuild", service.ProcessedBuildEvent.Timestamp ); buildEvent.BuildEventContext = s_buildEventContext; Assert.IsTrue(buildEvent.IsEquivalent((BuildErrorEventArgs)service.ProcessedBuildEvent)); }
/// <summary> /// Log a given build event and verify it is sent to ProcessLoggingEvent /// </summary> /// <param name="expectedBuildEvent">BuildEvent to log and expect from ProcessLoggingEvent</param> /// <param name="loggingService">LoggingService to log event to</param> private void LogandVerifyBuildEvent(BuildEventArgs expectedBuildEvent, ProcessBuildEventHelper loggingService) { loggingService.LogBuildEvent(expectedBuildEvent); Assert.IsTrue(loggingService.ProcessedBuildEvent.IsEquivalent(expectedBuildEvent), "Expected ProcessedBuildEvent to equal expected build event"); loggingService.ResetProcessedBuildEvent(); }
/// <summary> /// Create a projectStarted event to compare to the one which was passed into the ProcessedBuildEvent method. /// </summary> /// <param name="service">LoggingService mock object which overrides ProcessBuildEvent and can provide a ProcessedBuildEvent (the event which would have been sent to the loggers)</param> /// <param name="projectId">ProjectId to create the comparison event with.</param> /// <param name="message">Message to create the comparison event with.</param> /// <param name="projectFile">ProjectFile to create the comparison event with.</param> /// <param name="targetNames">TargetNames to create the comparison event with.</param> /// <param name="parentBuildEventContext">ParentBuildEventContext to create the comparison event with.</param> private void VerifyProjectStartedEventArgs(ProcessBuildEventHelper service, int projectId, string message, string projectFile, string targetNames, BuildEventContext parentBuildEventContext, BuildEventContext generatedContext) { ProjectStartedEventArgs buildEvent = new ProjectStartedEventArgs ( projectId, message, null, // no help keyword projectFile, targetNames, null, null, parentBuildEventContext, service.ProcessedBuildEvent.Timestamp ); buildEvent.BuildEventContext = generatedContext; Assert.IsTrue(((ProjectStartedEventArgs)service.ProcessedBuildEvent).IsEquivalent(buildEvent)); }
/// <summary> /// Create a buildMessage event to compare to the one which was passed into the ProcessedBuildEvent method. /// </summary> /// <param name="service">LoggingService mock object which overrides ProcessBuildEvent and can provide a ProcessedBuildEvent (the event which would have been sent to the loggers)</param> /// <param name="messageImportance">Importance level create the comparison event with</param> /// <param name="message">Message to create the comparison event with</param> private void VerityBuildMessageEventArgs(ProcessBuildEventHelper service, MessageImportance messageImportance, string message) { BuildMessageEventArgs buildMessageEvent = new BuildMessageEventArgs ( message, null, "MSBuild", messageImportance, service.ProcessedBuildEvent.Timestamp ); buildMessageEvent.BuildEventContext = s_buildEventContext; Assert.IsTrue(((BuildMessageEventArgs)service.ProcessedBuildEvent).IsEquivalent(buildMessageEvent)); }
/// <summary> /// Create a projectFinished event to compare to the one which was passed into the ProcessedBuildEvent method. /// </summary> /// <param name="service">LoggingService mock object which overrides ProcessBuildEvent and can provide a ProcessedBuildEvent (the event which would have been sent to the loggers)</param> /// <param name="projectContext">The build event context that this ProjectFinished event should contain</param> /// <param name="message">Message to create the comparison event with.</param> /// <param name="projectFile">ProjectFile to create the comparison event with.</param> /// <param name="success">Success value to create the comparison event with</param> private void VerifyProjectFinishedEvent(ProcessBuildEventHelper service, BuildEventContext projectContext, string message, string projectFile, bool success) { ProjectFinishedEventArgs projectEvent = new ProjectFinishedEventArgs ( message, null, projectFile, success, service.ProcessedBuildEvent.Timestamp ); projectEvent.BuildEventContext = projectContext; Assert.IsTrue(((ProjectFinishedEventArgs)service.ProcessedBuildEvent).IsEquivalent(projectEvent)); }
/// <summary> /// Create a taskStarted event to compare to the one which was passed into the ProcessedBuildEvent method. /// </summary> /// <param name="taskName">TaskName to create the comparison event with.</param> /// <param name="projectFile">ProjectFile to create the comparison event with.</param> /// <param name="projectFileOfTask">ProjectFileOfTask to create the comparison event with.</param> /// <param name="message">Message to create the comparison event with.</param> /// <param name="service">LoggingService mock object which overrides ProcessBuildEvent and can provide a ProcessedBuildEvent (the event which would have been sent to the loggers)</param> private void VerifyTaskStartedEvent(string taskName, string projectFile, string projectFileOfTask, string message, ProcessBuildEventHelper service) { TaskStartedEventArgs taskEvent = new TaskStartedEventArgs ( message, null, // no help keyword projectFile, projectFileOfTask, taskName, service.ProcessedBuildEvent.Timestamp ); taskEvent.BuildEventContext = s_buildEventContext; Assert.IsTrue(((TaskStartedEventArgs)service.ProcessedBuildEvent).IsEquivalent(taskEvent)); }
/// <summary> /// Create a TaskFinished event to compare to the one which was passed into the ProcessedBuildEvent method. /// </summary> /// <param name="taskName">TaskName to create the comparison event with.</param> /// <param name="projectFile">ProjectFile to create the comparison event with.</param> /// <param name="projectFileOfTask">ProjectFileOfTask to create the comparison event with.</param> /// <param name="succeeded">Succeeded value to create the comparison event with.</param> /// <param name="message">Message to create the comparison event with.</param> /// <param name="service">LoggingService mock object which overrides ProcessBuildEvent and can provide a ProcessedBuildEvent (the event which would have been sent to the loggers)</param> private void VerifyTaskFinishedEvent(string taskName, string projectFile, string projectFileOfTask, bool succeeded, string message, ProcessBuildEventHelper service) { TaskFinishedEventArgs taskEvent = new TaskFinishedEventArgs ( message, null, projectFile, projectFileOfTask, taskName, succeeded, service.ProcessedBuildEvent.Timestamp ); taskEvent.BuildEventContext = s_buildEventContext; Assert.IsTrue(((TaskFinishedEventArgs)service.ProcessedBuildEvent).IsEquivalent(taskEvent)); }
/// <summary> /// Create a TargetStarted event to compare to the one which was passed into the ProcessedBuildEvent method. /// </summary> /// <param name="targetName">TaskName to create the comparison event with.</param> /// <param name="projectFile">ProjectFile to create the comparison event with.</param> /// <param name="projectFileOfTarget">ProjectFileOfTarget to create the comparison event with.</param> /// <param name="message">Message to create the comparison event with.</param> /// <param name="service">LoggingService mock object which overrides ProcessBuildEvent and can provide a ProcessedBuildEvent (the event which would have been sent to the loggers)</param> private void VerifyTargetStartedEvent(string targetName, string projectFile, string projectFileOfTarget, string message, ProcessBuildEventHelper service) { TargetStartedEventArgs buildEvent = new TargetStartedEventArgs ( message, null, // no help keyword targetName, projectFile, projectFileOfTarget, String.Empty, service.ProcessedBuildEvent.Timestamp ); buildEvent.BuildEventContext = s_targetBuildEventContext; Assert.IsTrue(((TargetStartedEventArgs)service.ProcessedBuildEvent).IsEquivalent(buildEvent)); }
/// <summary> /// Create a TargetFinished event to compare to the one which was passed into the ProcessedBuildEvent method. /// </summary> /// <param name="targetName">TargetName to create the comparison event with.</param> /// <param name="projectFile">ProjectFile to create the comparison event with.</param> /// <param name="projectFileOfTarget">ProjectFileOfTarget to create the comparison event with.</param> /// <param name="succeeded">Succeeded value to create the comparison event with.</param> /// <param name="message">Message to create the comparison event with.</param> /// <param name="service">LoggingService mock object which overrides ProcessBuildEvent and can provide a ProcessedBuildEvent (the event which would have been sent to the loggers)</param> private void VerifyTargetFinishedEvent(string targetName, string projectFile, string projectFileOfTarget, bool succeeded, string message, ProcessBuildEventHelper service, IEnumerable targetOutputs) { TargetFinishedEventArgs targetEvent = new TargetFinishedEventArgs ( message, null, targetName, projectFile, projectFileOfTarget, succeeded, service.ProcessedBuildEvent.Timestamp, targetOutputs ); targetEvent.BuildEventContext = s_targetBuildEventContext; Assert.IsTrue(((TargetFinishedEventArgs)service.ProcessedBuildEvent).IsEquivalent(targetEvent)); }