Esempio n. 1
0
 protected void AssertContainsMessage(string message, vsBuildErrorLevel errorLevel)
 {
     if (!AreErrorItemsContainingTestMessage(message, errorLevel))
     {
         log.Info("Test suite " + _testFunctionBlockInstance + " does not report: " + message);
     }
 }
Esempio n. 2
0
        /// <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);
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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");
            }
        }
Esempio n. 5
0
 public Error(ErrorItem item)
 {
     Description = item.Description.ToUpper();
     ErrorLevel  = item.ErrorLevel;
 }
Esempio n. 6
0
        /// <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);
            }
        }
Esempio n. 7
0
 private int CountErrorItemsContainingTestMessage(string testMessage, vsBuildErrorLevel errorLevel)
 {
     return(_errors.Count(s => (s.Description.Contains(testMessage.ToUpper())) && s.ErrorLevel.Equals(errorLevel)));
 }
Esempio n. 8
0
 private bool AreErrorItemsContainingTestMessage(string testMessage, vsBuildErrorLevel errorLevel)
 {
     return(_errors.Any(e => (e.Description.Contains(testMessage.ToUpper())) && e.ErrorLevel.Equals(errorLevel)));
 }
Esempio n. 9
0
 public Error(ErrorItem item)
 {
     Description = item.Description;
     ErrorLevel  = item.ErrorLevel;
 }
Esempio n. 10
0
 public ErrorGlyphTag(string errorDescription, vsBuildErrorLevel errorLevel)
 {
     Description = errorDescription;
     ErrorLevel  = errorLevel;
 }