~nunit-core/nunitv2/2.5

« back to all changes in this revision

Viewing changes to src/NUnitFramework/core/SummaryVisitor.cs

  • Committer: jnewkirk
  • Date: 2002-07-10 20:00:13 UTC
  • Revision ID: vcs-imports@canonical.com-20020710200013-j8us5mbi0usp7p02
initialĀ load

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// Copyright (C) 2002. James W. Newkirk, Michael C. Two, Alexei A. Vorontsov. All Rights Reserved.
 
3
//
 
4
namespace Nunit.Core
 
5
{
 
6
        using System;
 
7
 
 
8
        /// <summary>
 
9
        /// Summary description for SiummaryVisitor.
 
10
        /// </summary>
 
11
        public class SummaryVisitor : ResultVisitor
 
12
        {
 
13
                private int totalCount;
 
14
                private int failureCount;
 
15
                private int testsNotRun;
 
16
                private int suitesNotRun;
 
17
                
 
18
                private double time;
 
19
                private string name;
 
20
                private bool initialized;
 
21
 
 
22
                public SummaryVisitor()
 
23
                {
 
24
                        totalCount = 0;
 
25
                        initialized = false;
 
26
                }
 
27
 
 
28
                public void visit(TestCaseResult caseResult) 
 
29
                {
 
30
                        if(caseResult.Executed)
 
31
                        {
 
32
                                totalCount++;
 
33
                                if(caseResult.IsFailure)
 
34
                                        failureCount++;
 
35
                        }
 
36
                        else
 
37
                                testsNotRun++;
 
38
                }
 
39
 
 
40
                public void visit(TestSuiteResult suiteResult) 
 
41
                {
 
42
                        SetNameandTime(suiteResult.Name, suiteResult.Time);
 
43
 
 
44
                        
 
45
                        
 
46
                        foreach (TestResult result in suiteResult.Results)
 
47
                        {
 
48
                                result.Accept(this);
 
49
                        }
 
50
                        
 
51
                        if(!suiteResult.Executed)
 
52
                                suitesNotRun++;
 
53
                }
 
54
 
 
55
                public double Time
 
56
                {
 
57
                        get { return time; }
 
58
                }
 
59
 
 
60
                private void SetNameandTime(string name, double time)
 
61
                {
 
62
                        if(!initialized)
 
63
                        {
 
64
                                this.time = time;
 
65
                                this.name = name;
 
66
                                initialized = true;
 
67
                        }
 
68
                }
 
69
 
 
70
                public bool Success
 
71
                {
 
72
                        get { return (failureCount == 0); }
 
73
                }
 
74
 
 
75
                public int Count
 
76
                {
 
77
                        get { return totalCount; }
 
78
                }
 
79
 
 
80
                public int Failures
 
81
                {
 
82
                        get { return failureCount; }
 
83
                }
 
84
 
 
85
                public int TestsNotRun
 
86
                {
 
87
                        get { return testsNotRun; }
 
88
                }
 
89
 
 
90
                public int SuitesNotRun
 
91
                {
 
92
                        get { return suitesNotRun; }
 
93
                }
 
94
 
 
95
                public string Name
 
96
                {
 
97
                        get { return name; }
 
98
                }
 
99
        }
 
100
}