public InvalidLogRecordException(string message) : base(message) { RecoveredTest = null; }
/// <summary> /// /// </summary> /// <exception cref="UnrealScriptUnitTestParser.InvalidLogRecordException">Thrown if input string has wrong format and cannot be parsed</exception> /// <param name="source"></param> /// <returns></returns> public TestInfo ParseRecord(string source) { var matches = _logRecordRegex.Matches(source); if(matches.Count!=1) { var message = String.Format(@"Regular expression found {0} occurances of the pattern while awaited 1. The source string '{1}' ", matches.Count, source); throw new InvalidLogRecordException(message); } var testInfo = new TestInfo{RecordFullText = source}; var match = matches[0]; //Parse first part testInfo.Time = TimeSpan.FromSeconds(Double.Parse(match.Groups["time"].Value)); testInfo.SourceString = match.Groups["location"].Value; testInfo.Message = match.Groups["message"].Value; testInfo.AssertionName = match.Groups["assertion"].Value; //Obtain values array from t string valueStr = match.Groups["values"].Value; string[] values; if(valueStr.Contains(StringValueSeparator)) //It has several strings { values = valueStr.Split(new []{StringValueSeparator}, StringSplitOptions.RemoveEmptyEntries); } else if (valueStr.Contains(NumberValueSeparator)) //values have several ints { values = valueStr.Split(new[] { NumberValueSeparator }, StringSplitOptions.RemoveEmptyEntries); } else { //It doesn't have any separator, it is a one value values = new []{valueStr}; } testInfo.AssertionValues = values; //Run assertion!!! var assertResult = AssertionManger.TestAssertion(testInfo.AssertionName, testInfo.AssertionValues); testInfo.Result = assertResult.Result; testInfo.FailureReason = assertResult.FailureReason; //return what we've got return testInfo; }
private void ShowTestInfo(TestInfo test) { string text = String.Format( "Time: {7}{0}{0}" + //TODO right order "Result : {1}{0}{0}" + "Type: {2}{0}{0}" + "Failure: {3}{0}{0}" + "Values: {4}{0}{0}" + "Message: {6}{0}{0}" + "Source: {5}{0}{0}", Environment.NewLine, test.Result, test.AssertionName, test.FailureReason??"", test.AssertionValues.Aggregate((a, b) => a + ", " + b), test.SourceString, test.Message, test.Time ); TestInfoTextBox.Text = text; }