Beispiel #1
0
        /// <summary>
        /// Perform unordered verification of the list of MSBuildMessages
        /// </summary>
        /// <param name="output">The standard output</param>
        /// <returns>A list of errors encountered during verification</returns>
        private List <string> MSBuildMessageVerification(string output)
        {
            List <string> errors = new List <string>();

            if (null == this.ExpectedMSBuildMessages)
            {
                return(errors);
            }

            List <MSBuildMessage> actualMSBuildMessages = this.FindActualMSBuildMessages(output);

            for (int i = 0; i < this.ExpectedMSBuildMessages.Count; i++)
            {
                // If the expectedMessage does not have any specified MessageText then ignore it in a comparison
                bool ignoreText = String.IsNullOrEmpty(this.ExpectedMSBuildMessages[i].MessageText);

                // Flip this bool to true if the expected message is in the list of actual message that were printed
                bool expectedMessageWasFound = false;

                for (int j = 0; j < actualMSBuildMessages.Count; j++)
                {
                    if (null != actualMSBuildMessages[j] && 0 == MSBuildMessage.Compare(actualMSBuildMessages[j], this.ExpectedMSBuildMessages[i], ignoreText))
                    {
                        // Invalidate the message from the list of found errors by setting it to null
                        actualMSBuildMessages[j] = null;

                        expectedMessageWasFound = true;
                    }
                }

                // Check if the expected message was found in the list of actual messages
                if (!expectedMessageWasFound)
                {
                    errors.Add(String.Format("Could not find the expected message: {0}", this.ExpectedMSBuildMessages[i].ToString()));
                }
            }

            if (!this.IgnoreExtraMSBuildMessages)
            {
                // Now go through the messages that were found but that weren't expected
                foreach (MSBuildMessage actualMSBuildMessage in actualMSBuildMessages)
                {
                    if (null != actualMSBuildMessage)
                    {
                        errors.Add(String.Format("Found an unexpected message: {0}", actualMSBuildMessage.ToString()));
                    }
                }
            }

            return(errors);
        }
Beispiel #2
0
        /// <summary>
        /// Helper method for finding all the errors and all the warnings in the output
        /// </summary>
        /// <returns>A list of MSBuildMessage in the output</returns>
        private List <MSBuildMessage> FindActualMSBuildMessages(string output)
        {
            List <MSBuildMessage> actualMSBuildMessages = new List <MSBuildMessage>();

            foreach (string line in output.Split('\n', '\r'))
            {
                MSBuildMessage actualWixMessage = MSBuildMessage.FindMSBuildMessage(line);

                if (null != actualWixMessage)
                {
                    actualMSBuildMessages.Add(actualWixMessage);
                }
            }

            return(actualMSBuildMessages);
        }