protected void AssertContainsMessage(string message, vsBuildErrorLevel errorLevel) { if (!AreErrorItemsContainingTestMessage(message, errorLevel)) { log.Info("Test suite " + _testFunctionBlockInstance + " does not report: " + message); } }
/// <summary> /// Asserts that at least one message in the array exists /// </summary> protected void AssertContainsAtLeastOneMessage(string[] messages, vsBuildErrorLevel errorLevel) { bool foundMessage = false; foreach (string s in messages) { if (AreErrorItemsContainingTestMessage(s, errorLevel)) { foundMessage = true; break; } } if (!foundMessage) { string print; print = "Test suite " + _testFunctionBlockInstance + " does not report any of the messages: ["; foreach (string s in messages) { print = print + s + ","; } print = print + "]"; log.Info(print); } }
private static async Task <string[]> GetErrorTasksAsync(vsBuildErrorLevel errorLevel) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var dte = ServiceLocator.GetInstance <DTE>(); dte.ExecuteCommand("View.ErrorList", " "); Window errorListWindow = null; foreach (Window window in dte.Windows) { if (window.Caption.StartsWith(ErrorListWindowCaption, System.StringComparison.OrdinalIgnoreCase)) { errorListWindow = window; break; } } if (errorListWindow == null) { throw new InvalidOperationException("Unable to locate the error list"); } ErrorList errorList = errorListWindow.Object as ErrorList; if (errorList == null) { throw new InvalidOperationException("Unable to retrieve the error list"); } errorList.ShowErrors = true; errorList.ShowWarnings = true; errorList.ShowMessages = true; var errorItems = errorList.ErrorItems as ErrorItems; if (errorItems == null) { throw new InvalidOperationException("Unable to retrieve the error list items"); } var errorTasks = new List <ErrorItem>(); for (int i = 1; i <= errorItems.Count; i++) { var errorItem = errorItems.Item(i); var currentErrorLevel = (vsBuildErrorLevel)errorItem.ErrorLevel; if (currentErrorLevel == errorLevel) { errorTasks.Add(errorItem); } } var items = errorTasks.Select(e => e.Description as string).ToArray(); return(items); }
protected void AssertMessageCount(string message, int messageCount, vsBuildErrorLevel errorLevel) { int actualCount = CountErrorItemsContainingTestMessage(message, errorLevel); if (actualCount != messageCount) { log.Info("Test suite " + _testFunctionBlockInstance + " reports message " + message + " " + actualCount + " times"); } }
public Error(ErrorItem item) { Description = item.Description.ToUpper(); ErrorLevel = item.ErrorLevel; }
/// <summary> /// Asserts that at least one of the messages in the array exists the messageCount amount of times. Note that if the messageCount will /// increase also if both messages exist. /// </summary> protected void AssertAtLeastOneMessageCount(string[] messages, int messageCount, vsBuildErrorLevel errorLevel) { int actualCount = 0; string print; foreach (string s in messages) { int count = CountErrorItemsContainingTestMessage(s, errorLevel); actualCount = actualCount + count; } if (actualCount != messageCount) { print = "Test suite " + _testFunctionBlockInstance + " reports the messages ["; foreach (string s in messages) { print = print + s + ","; } print = print + "] "; print = print + actualCount + " times"; log.Info(print); } }
private int CountErrorItemsContainingTestMessage(string testMessage, vsBuildErrorLevel errorLevel) { return(_errors.Count(s => (s.Description.Contains(testMessage.ToUpper())) && s.ErrorLevel.Equals(errorLevel))); }
private bool AreErrorItemsContainingTestMessage(string testMessage, vsBuildErrorLevel errorLevel) { return(_errors.Any(e => (e.Description.Contains(testMessage.ToUpper())) && e.ErrorLevel.Equals(errorLevel))); }
public Error(ErrorItem item) { Description = item.Description; ErrorLevel = item.ErrorLevel; }
public ErrorGlyphTag(string errorDescription, vsBuildErrorLevel errorLevel) { Description = errorDescription; ErrorLevel = errorLevel; }