/// <summary> /// Perform unordered verification of the list of WixMessages /// </summary> /// <param name="output">The standard output</param> /// <returns>A list of errors encountered during verification</returns> private List <string> UnorderedWixMessageVerification(string output) { List <string> errors = new List <string>(); if (null == this.ExpectedWixMessages) { return(errors); } List <WixMessage> actualWixMessages = this.FindActualWixMessages(output); for (int i = 0; i < this.ExpectedWixMessages.Count; i++) { // If the expectedMessage does not have any specified MessageText then ignore it in a comparison bool ignoreText = String.IsNullOrEmpty(this.ExpectedWixMessages[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 < actualWixMessages.Count; j++) { if (null != actualWixMessages[j] && 0 == WixMessage.Compare(actualWixMessages[j], this.ExpectedWixMessages[i], ignoreText)) { // Invalidate the message from the list of found errors by setting it to null actualWixMessages[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.ExpectedWixMessages[i].ToString())); if (String.IsNullOrEmpty(this.ExpectedWixMessages[i].MessageText)) { errors.Add(" When unordered WixMessage verification is performed, WixMessage text is not ignored"); } } } if (!this.IgnoreExtraWixMessages) { // Now go through the messages that were found but that weren't expected foreach (WixMessage actualWixMessage in actualWixMessages) { if (null != actualWixMessage) { errors.Add(String.Format("Found an unexpected message: {0}", actualWixMessage.ToString())); } } } return(errors); }
/// <summary> /// Perform ordered verification of the list of WixMessages /// </summary> /// <param name="output">The standard output</param> /// <returns>A list of errors encountered during verification</returns> private List <string> OrderedWixMessageVerification(string output) { List <string> errors = new List <string>(); if (null == this.ExpectedWixMessages) { return(errors); } List <WixMessage> actualWixMessages = this.FindActualWixMessages(output); for (int i = 0; i < this.ExpectedWixMessages.Count; i++) { // If the expectedMessage does not have any specified MessageText then ignore it in a comparison bool ignoreText = String.IsNullOrEmpty(this.ExpectedWixMessages[i].MessageText); if (i >= this.ExpectedWixMessages.Count) { // there are more actual WixMessages than expected break; } else if (i >= actualWixMessages.Count || 0 != WixMessage.Compare(actualWixMessages[i], this.ExpectedWixMessages[i], ignoreText)) { errors.Add(String.Format("Ordered WixMessage verification failed when trying to find the expected message {0}", expectedWixMessages[i])); break; } else { // the expected WixMessage was found actualWixMessages[i] = null; } } if (!this.IgnoreExtraWixMessages) { // Now go through the messages that were found but that weren't expected foreach (WixMessage actualWixMessage in actualWixMessages) { if (null != actualWixMessage) { errors.Add(String.Format("Found an unexpected message: {0}", actualWixMessage.ToString())); } } } return(errors); }