namespace NUnit.Framework {
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
/// A TestFailure collects a failed test together with
/// the caught exception.
///
public class TestFailure {
private readonly ITest failedTest;
private readonly Exception thrownException;
/// Constructs a TestFailure with the given test and
/// exception.
public TestFailure(ITest theFailedTest, Exception theThrownException) {
failedTest= theFailedTest;
thrownException= theThrownException;
}
/// Gets the failed test.
public ITest FailedTest {
get { return failedTest; }
}
/// True if it's a failure, false if error.
public bool IsFailure {
get { return thrownException is AssertionFailedError; }
}
/// Gets the thrown exception.
public Exception ThrownException {
get { return thrownException; }
}
/// Returns a short description of the failure.
public override string ToString() {
StringBuilder buffer= new StringBuilder();
buffer.Append(failedTest+": "+thrownException.Message);
return buffer.ToString();
}
}
}