new test + update
[mono.git] / mcs / nunit20 / core / TestResult.cs
old mode 100755 (executable)
new mode 100644 (file)
index 6cb06d0..51204eb
@@ -38,16 +38,63 @@ namespace NUnit.Core
        [Serializable]
        public abstract class TestResult
        {
+               #region Fields
+
+               /// <summary>
+               /// True if the test executed
+               /// </summary>
                private bool executed;
+
+               /// <summary>
+               /// True if the test was marked as a failure
+               /// </summary>
                private bool isFailure; 
+
+               /// <summary>
+               /// True if the setup failed: This means SetUp for a test case,
+               /// or TestFixtureSetUp for a fixture.
+               /// </summary>
+               private bool setupFailure;
+               
+               /// <summary>
+               /// The elapsed time for executing this test
+               /// </summary>
                private double time;
+
+               /// <summary>
+               /// The name of the test
+               /// </summary>
                private string name;
+
+               /// <summary>
+               /// The test that this result pertains to
+               /// </summary>
                private ITest test;
+
+               /// <summary>
+               /// The stacktrace at the point of failure
+               /// </summary>
                private string stackTrace;
+
+               /// <summary>
+               /// Description of this test
+               /// </summary>
                private string description;
+
+               /// <summary>
+               /// Message giving the reason for failure
+               /// </summary>
                protected string messageString;
+
+               /// <summary>
+               /// Number of asserts executed by this test
+               /// </summary>
                private int assertCount;
 
+               #endregion
+
+               #region Protected Constructor
+
                protected TestResult(ITest test, string name)
                {
                        this.name = name;
@@ -56,6 +103,10 @@ namespace NUnit.Core
                                this.description = test.Description;
                }
 
+               #endregion
+
+               #region Properties
+
                public bool Executed 
                {
                        get { return executed; }
@@ -88,6 +139,12 @@ namespace NUnit.Core
                        set { isFailure = value; }
                }
 
+               public bool SetupFailure
+               {
+                       get { return setupFailure; }
+                       set { setupFailure = value; }
+               }
+
                public virtual string Description
                {
                        get { return description; }
@@ -123,7 +180,31 @@ namespace NUnit.Core
                        set { assertCount = value; }
                }
 
-               public abstract void NotRun(string message);
+               #endregion
+
+               #region Public Methods
+
+               public void NotRun(string reason)
+               {
+                       this.executed = false;
+                       this.messageString = reason;
+               }
+
+               public void Failure(string message, string stackTrace )
+               {
+                       Failure( message, stackTrace, false );
+               }
+
+               public void Failure(string message, string stackTrace, bool setupFailure)
+               {
+                       this.executed = true;
+                       this.isFailure = true;
+                       this.messageString = message;
+                       this.stackTrace = stackTrace;
+                       this.setupFailure = setupFailure;
+               }
+
+               #endregion
 
                public abstract void Accept(ResultVisitor visitor);
        }