mbunit2 2.4.2.355.20100801
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/docs/ASL - Apache Software Foundation License.txt +57 -0
- data/docs/MbUnit License.txt +14 -0
- data/docs/MbUnit.chm +0 -0
- data/docs/Release Notes.txt +7 -0
- data/docs/extras/CCNet/How to use MbUnit v2 with CruiseControl.Net.txt +88 -0
- data/docs/extras/CCNet/images/Category.png +0 -0
- data/docs/extras/CCNet/images/Fixture.png +0 -0
- data/docs/extras/CCNet/images/Populator.png +0 -0
- data/docs/extras/CCNet/images/Test.png +0 -0
- data/docs/extras/CCNet/xsl/MBUnitDetails.xsl +592 -0
- data/docs/extras/CCNet/xsl/MBUnitSummary.xsl +266 -0
- data/docs/extras/Snippets/AdjacencyGraph.cst +1703 -0
- data/docs/extras/Snippets/AssertWrapper.cst +181 -0
- data/docs/extras/Snippets/CrudPopulator.cst +377 -0
- data/docs/extras/Snippets/DatabasePopulator.cst +386 -0
- data/docs/extras/Snippets/DatabasePopulatorCrudTest.cst +177 -0
- data/docs/extras/Snippets/Exception.cst +94 -0
- data/docs/extras/Snippets/GrammarPopulator.cst +258 -0
- data/docs/extras/Snippets/MockObject.cst +296 -0
- data/docs/extras/Snippets/RapTierCrudPopulator.cst +444 -0
- data/docs/extras/Snippets/SimpleFixture.cst +91 -0
- data/docs/extras/Snippets/SqlppCrudPopulator.cst +443 -0
- data/docs/extras/Snippets/TestFixture.cst +469 -0
- data/docs/extras/Snippets/autorunner.snippet +45 -0
- data/docs/extras/Snippets/combinatorialtest.snippet +54 -0
- data/docs/extras/Snippets/datafixture.snippet +61 -0
- data/docs/extras/Snippets/model.snippet +95 -0
- data/docs/extras/Snippets/msbuild.snippet +40 -0
- data/docs/extras/Snippets/nant.snippet +34 -0
- data/docs/extras/Snippets/perfcounterassert.cst +173 -0
- data/docs/extras/Snippets/processtestfixture.snippet +75 -0
- data/docs/extras/Snippets/rowtest.snippet +113 -0
- data/docs/extras/Snippets/state.snippet +27 -0
- data/docs/extras/Snippets/submodel.snippet +32 -0
- data/docs/extras/Snippets/test.snippet +28 -0
- data/docs/extras/Snippets/testexpectedexception.snippet +32 -0
- data/docs/extras/Snippets/testfixture.snippet +68 -0
- data/docs/extras/Snippets/testsuitefixture.snippet +48 -0
- data/docs/extras/Snippets/typefixture.snippet +74 -0
- data/docs/extras/Snippets/typefixturewithproviderfactory.snippet +77 -0
- data/docs/extras/Snippets/usingmbunit.snippet +19 -0
- data/docs/extras/Templates/VS2005/ItemTemplates/CSharp/Test/MbUnit2.TestFixtureTemplate.CSharp.zip +0 -0
- data/docs/extras/Templates/VS2005/ItemTemplates/VisualBasic/Test/MbUnit2.TestFixtureTemplate.VisualBasic.zip +0 -0
- data/docs/extras/Templates/VS2005/ProjectTemplates/CSharp/Test/MbUnit2.TestProjectTemplate.CSharp.zip +0 -0
- data/docs/extras/Templates/VS2005/ProjectTemplates/VisualBasic/Test/MbUnit2.TestProjectTemplate.VisualBasic.zip +0 -0
- data/docs/extras/Templates/VS2008/ItemTemplates/CSharp/Test/MbUnit2.TestFixtureTemplate.CSharp.zip +0 -0
- data/docs/extras/Templates/VS2008/ItemTemplates/VisualBasic/Test/MbUnit2.TestFixtureTemplate.VisualBasic.zip +0 -0
- data/docs/extras/Templates/VS2008/ProjectTemplates/CSharp/Test/MbUnit2.MvcWebApplicationTestProjectTemplate.CSharp.zip +0 -0
- data/docs/extras/Templates/VS2008/ProjectTemplates/CSharp/Test/MbUnit2.TestProjectTemplate.CSharp.zip +0 -0
- data/docs/extras/Templates/VS2008/ProjectTemplates/VisualBasic/Test/MbUnit2.MvcWebApplicationTestProjectTemplate.VisualBasic.zip +0 -0
- data/docs/extras/Templates/VS2008/ProjectTemplates/VisualBasic/Test/MbUnit2.TestProjectTemplate.VisualBasic.zip +0 -0
- data/lib/MbUnit License.txt +14 -0
- data/lib/MbUnit.AddIn.dll +0 -0
- data/lib/MbUnit.Cons.exe +0 -0
- data/lib/MbUnit.Cons.exe.config +12 -0
- data/lib/MbUnit.Framework.2.0.dll +0 -0
- data/lib/MbUnit.Framework.2.0.pdb +0 -0
- data/lib/MbUnit.Framework.2.0.xml +278 -0
- data/lib/MbUnit.Framework.dll +0 -0
- data/lib/MbUnit.Framework.pdb +0 -0
- data/lib/MbUnit.Framework.xml +6929 -0
- data/lib/MbUnit.GUI.exe +0 -0
- data/lib/MbUnit.GUI.exe.config +14 -0
- data/lib/MbUnit.MSBuild.Tasks.dll +0 -0
- data/lib/MbUnit.Tasks.dll +0 -0
- data/lib/NGraphviz.Helpers.dll +0 -0
- data/lib/NGraphviz.Layout.dll +0 -0
- data/lib/NGraphviz.dll +0 -0
- data/lib/QuickGraph.Algorithms.Graphviz.dll +0 -0
- data/lib/QuickGraph.Algorithms.dll +0 -0
- data/lib/QuickGraph.Algorithms.pdb +0 -0
- data/lib/QuickGraph.Algorithms.xml +2818 -0
- data/lib/QuickGraph.dll +0 -0
- data/lib/QuickGraph.pdb +0 -0
- data/lib/QuickGraph.xml +3126 -0
- data/lib/Refly.dll +0 -0
- data/lib/Refly.pdb +0 -0
- data/lib/Refly.xml +1327 -0
- data/lib/TestFu.dll +0 -0
- data/lib/TestFu.pdb +0 -0
- data/lib/TestFu.xml +1932 -0
- data/lib/XsdTidy.exe +0 -0
- metadata +163 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
|
3
|
+
<CodeSnippet Format="1.0.0">
|
4
|
+
<Header>
|
5
|
+
<Title>AutoRunner</Title>
|
6
|
+
<Author>MbUnit</Author>
|
7
|
+
<Description>Expansion snippet for a AutorRunner main.</Description>
|
8
|
+
<Shortcut>autorunner</Shortcut>
|
9
|
+
<SnippetTypes>
|
10
|
+
<SnippetType>Expansion</SnippetType>
|
11
|
+
</SnippetTypes>
|
12
|
+
</Header>
|
13
|
+
<Snippet>
|
14
|
+
<Declarations>
|
15
|
+
<Literal>
|
16
|
+
<ID>name</ID>
|
17
|
+
<ToolTip>Main class name</ToolTip>
|
18
|
+
<Default>Program</Default>
|
19
|
+
</Literal>
|
20
|
+
<Literal>
|
21
|
+
<ID>namespace</ID>
|
22
|
+
<Default>MbUnitTests</Default>
|
23
|
+
</Literal>
|
24
|
+
</Declarations>
|
25
|
+
<Code Language="VB"><![CDATA[Imports System
|
26
|
+
Imports MbUnit.Core
|
27
|
+
'Imports MbUnit.Core.Filters
|
28
|
+
|
29
|
+
Namespace $namespace$
|
30
|
+
Class $name$
|
31
|
+
Public Shared Sub Main()
|
32
|
+
Using auto As AutoRunner = New AutoRunner()
|
33
|
+
' Note: uncomment "Imports MbUnit.Core.Filters" and the following line if you want to
|
34
|
+
' execute only the fixtures that are tagged with <CurrentFixture()> attribute.
|
35
|
+
|
36
|
+
' auto.Domain.Filter = FixtureFilters.Current
|
37
|
+
auto.Run()
|
38
|
+
auto.ReportToHtml()
|
39
|
+
End Using
|
40
|
+
End Sub
|
41
|
+
End Class
|
42
|
+
End Namespace]]></Code>
|
43
|
+
</Snippet>
|
44
|
+
</CodeSnippet>
|
45
|
+
</CodeSnippets>
|
@@ -0,0 +1,54 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
|
3
|
+
<CodeSnippet Format="1.0.0">
|
4
|
+
<Header>
|
5
|
+
<Title>CombinatorialTest</Title>
|
6
|
+
<Author>MbUnit</Author>
|
7
|
+
<Description>Inserts a combinatorial test with 2 parameters and 2 factories</Description>
|
8
|
+
<HelpUrl>http://www.mertner.com/confluence/display/MbUnit/CombinatorialTestAttribute</HelpUrl>
|
9
|
+
<Shortcut>combinatorial</Shortcut>
|
10
|
+
</Header>
|
11
|
+
<Snippet>
|
12
|
+
<Declarations>
|
13
|
+
<Literal>
|
14
|
+
<ID>testName</ID>
|
15
|
+
<Default>Test</Default>
|
16
|
+
</Literal>
|
17
|
+
<Literal>
|
18
|
+
<ID>type1</ID>
|
19
|
+
</Literal>
|
20
|
+
<Literal>
|
21
|
+
<ID>type2</ID>
|
22
|
+
<Default>type2</Default>
|
23
|
+
</Literal>
|
24
|
+
<Literal>
|
25
|
+
<ID>arg1Name</ID>
|
26
|
+
<Default>arg1Name</Default>
|
27
|
+
</Literal>
|
28
|
+
<Literal>
|
29
|
+
<ID>arg2Name</ID>
|
30
|
+
<Default>arg2Name</Default>
|
31
|
+
</Literal>
|
32
|
+
</Declarations>
|
33
|
+
<Code Language="VB"><![CDATA[ <CombinatorialTest()> _
|
34
|
+
Public Sub $testName$( _
|
35
|
+
<UsingFactories("$type1$Factory")] ByVal $arg1Name$ As $type1$, _
|
36
|
+
<UsingFactories("$type2$Factory")] ByVal $arg2Name$ As $type2$)
|
37
|
+
|
38
|
+
End Sub
|
39
|
+
|
40
|
+
<Factory(GetType($type1$))> _
|
41
|
+
public IEnumerable $type1$Factory()
|
42
|
+
{
|
43
|
+
Dim values As $type1$() = New $type1$ { };
|
44
|
+
Return values
|
45
|
+
}
|
46
|
+
|
47
|
+
<Factory(GetType($type2$))> _
|
48
|
+
Public Function $type2$Factory() As IEnumerable
|
49
|
+
Dim values As $type2$() = New $type2$ { };
|
50
|
+
Return values
|
51
|
+
End Function]]></Code>
|
52
|
+
</Snippet>
|
53
|
+
</CodeSnippet>
|
54
|
+
</CodeSnippets>
|
@@ -0,0 +1,61 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
|
3
|
+
<CodeSnippet Format="1.0.0">
|
4
|
+
<Header>
|
5
|
+
<Title>DataFixture</Title>
|
6
|
+
<Author>MbUnit</Author>
|
7
|
+
<Description>Expansion snippet for DataFixture</Description>
|
8
|
+
<HelpUrl>http://www.mertner.com/confluence/display/MbUnit/DataFixture</HelpUrl>
|
9
|
+
<Shortcut>datafixture</Shortcut>
|
10
|
+
<SnippetTypes>
|
11
|
+
<SnippetType>Expansion</SnippetType>
|
12
|
+
</SnippetTypes>
|
13
|
+
</Header>
|
14
|
+
<Snippet>
|
15
|
+
<Declarations>
|
16
|
+
<Literal>
|
17
|
+
<ID>namespace</ID>
|
18
|
+
<ToolTip>Test namespace</ToolTip>
|
19
|
+
<Default>MbUnitTests</Default>
|
20
|
+
</Literal>
|
21
|
+
<Literal>
|
22
|
+
<ID>name</ID>
|
23
|
+
<ToolTip>Fixture name</ToolTip>
|
24
|
+
<Default>My</Default>
|
25
|
+
</Literal>
|
26
|
+
<Literal>
|
27
|
+
<ID>resource</ID>
|
28
|
+
<ToolTip>Resource name</ToolTip>
|
29
|
+
<Default>Put the xml resource name here</Default>
|
30
|
+
</Literal>
|
31
|
+
<Literal>
|
32
|
+
<ID>resourceXPath</ID>
|
33
|
+
<ToolTip>Data XPath</ToolTip>
|
34
|
+
<Default>Put the data XPath here</Default>
|
35
|
+
</Literal>
|
36
|
+
<Literal>
|
37
|
+
<ID>testXPath</ID>
|
38
|
+
<ToolTip>Resource XPath</ToolTip>
|
39
|
+
<Default>Put the test case XPath here</Default>
|
40
|
+
</Literal>
|
41
|
+
</Declarations>
|
42
|
+
<Code Language="VB"><![CDATA[Imports System
|
43
|
+
Imports System.Xml
|
44
|
+
Imports MbUnit.Framework
|
45
|
+
|
46
|
+
Namespace $namespace$
|
47
|
+
<DataFixture(), _
|
48
|
+
ResourceXmlDataProvider(GetType($name$Test),"$resource$","$resourceXPath$")> _
|
49
|
+
Public Class $name$Test
|
50
|
+
#Region "Test cases"
|
51
|
+
<ForEachTest("$testXPath$")> _
|
52
|
+
Public Sub ForEachTest(ByVal node As XmlNode)
|
53
|
+
|
54
|
+
End Sub
|
55
|
+
#End Region
|
56
|
+
End Class
|
57
|
+
End Namespace
|
58
|
+
]]></Code>
|
59
|
+
</Snippet>
|
60
|
+
</CodeSnippet>
|
61
|
+
</CodeSnippets>
|
@@ -0,0 +1,95 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
|
3
|
+
<CodeSnippet Format="1.0.0">
|
4
|
+
<Header>
|
5
|
+
<Title>Model</Title>
|
6
|
+
<Description>Expansion snippet for a Model</Description>
|
7
|
+
<Shortcut>model</Shortcut>
|
8
|
+
<SnippetTypes>
|
9
|
+
<SnippetType>Expansion</SnippetType>
|
10
|
+
</SnippetTypes>
|
11
|
+
</Header>
|
12
|
+
<Snippet>
|
13
|
+
<Declarations>
|
14
|
+
<Literal>
|
15
|
+
<ID>namespace</ID>
|
16
|
+
<ToolTip>Model namespace</ToolTip>
|
17
|
+
<Default>MbUnitTests</Default>
|
18
|
+
</Literal>
|
19
|
+
<Literal>
|
20
|
+
<ID>type</ID>
|
21
|
+
<ToolTip>Modelled type</ToolTip>
|
22
|
+
<Default>Put the modelled type here</Default>
|
23
|
+
</Literal>
|
24
|
+
<Literal>
|
25
|
+
<ID>basetype</ID>
|
26
|
+
<ToolTip>Modelled Base Type</ToolTip>
|
27
|
+
<Default>Object</Default>
|
28
|
+
</Literal>
|
29
|
+
</Declarations>
|
30
|
+
<Code Language="VB"><![CDATA[Imports System
|
31
|
+
Imports TestFu
|
32
|
+
Imports TestFu.Models
|
33
|
+
|
34
|
+
Namespace $namespace$
|
35
|
+
''' <summary>
|
36
|
+
''' A IModel implementation for the $type$ type.
|
37
|
+
''' </summary>
|
38
|
+
' <State("Put a state name here")>
|
39
|
+
' <SubModel("Put a submodel name here")>
|
40
|
+
<Model(GetType($type$))> _
|
41
|
+
Public Class $type$Model
|
42
|
+
Inherits $basetype$Model
|
43
|
+
|
44
|
+
#Region "Constructors"
|
45
|
+
''' <summary>
|
46
|
+
''' Initializes a new $type$Model instance.
|
47
|
+
''' </summary>
|
48
|
+
Public Sub New()
|
49
|
+
|
50
|
+
End Sub
|
51
|
+
|
52
|
+
''' <summary>
|
53
|
+
''' Initializes a new "$name$Model" instance to model the modelledType type.
|
54
|
+
''' </summary>
|
55
|
+
''' <param name="modelledType">
|
56
|
+
''' Target Type of the model
|
57
|
+
''' </param>
|
58
|
+
Public Sub New(ByVal modelledType As Type)
|
59
|
+
MyBase.New(modelledType)
|
60
|
+
If Not GetType($type$).IsAssignableFrom(modelledType)
|
61
|
+
Throw New ArgumentException("$type$ is not assignable from "+modelledType.FullName,"modelledType")
|
62
|
+
End If
|
63
|
+
End Sub
|
64
|
+
#End Region
|
65
|
+
|
66
|
+
#Region "Transitions"
|
67
|
+
<Transition()> _
|
68
|
+
Public Sub SampleTransition(ByVal target As $type$)
|
69
|
+
Throw New NotImplementedException()
|
70
|
+
End Sub
|
71
|
+
|
72
|
+
''' <summary>
|
73
|
+
''' Gets the active ITransition instance for current target.
|
74
|
+
''' </summary>
|
75
|
+
''' <param name="transitions">
|
76
|
+
''' Collection of active ITransition names
|
77
|
+
''' </param>
|
78
|
+
''' <param name="target">
|
79
|
+
''' Current tested instance
|
80
|
+
''' </param>
|
81
|
+
Protected Overrides Sub GetActiveTransitions( _
|
82
|
+
ByVal transitions as ITransitionNameCollection , _
|
83
|
+
ByVal target as Object)
|
84
|
+
|
85
|
+
MyBase.GetActiveTransitions(transitions,target)
|
86
|
+
Dim current As $type$ = DirectCast(target, $type$)
|
87
|
+
|
88
|
+
End Sub
|
89
|
+
#End Region
|
90
|
+
End Class
|
91
|
+
End Namespace
|
92
|
+
]]></Code>
|
93
|
+
</Snippet>
|
94
|
+
</CodeSnippet>
|
95
|
+
</CodeSnippets>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
|
3
|
+
<CodeSnippet Format="1.0.0">
|
4
|
+
<Header>
|
5
|
+
<Title>MSBuild task</Title>
|
6
|
+
<Author>MbUnit</Author>
|
7
|
+
<Description>Expansion snippet for a MSBuild task</Description>
|
8
|
+
<Shortcut>msbuild</Shortcut>
|
9
|
+
<SnippetTypes>
|
10
|
+
<SnippetType>Expansion</SnippetType>
|
11
|
+
</SnippetTypes>
|
12
|
+
</Header>
|
13
|
+
<Snippet>
|
14
|
+
<Declarations>
|
15
|
+
<Literal>
|
16
|
+
<ID>name</ID>
|
17
|
+
<ToolTip>Fixture name</ToolTip>
|
18
|
+
<Default>My</Default>
|
19
|
+
</Literal>
|
20
|
+
</Declarations>
|
21
|
+
<Code Language="XML"><![CDATA[<?xml version="1.0" encoding="utf-8" ?>
|
22
|
+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
23
|
+
<UsingTask AssemblyName="MbUnit.MSBuild.Tasks" TaskName="MbUnit.MSBuild.Tasks.MbUnit"/>
|
24
|
+
<ItemGroup>
|
25
|
+
<TestAssemblies Include="$end$" />
|
26
|
+
</ItemGroup>
|
27
|
+
<Target Name="Tests">
|
28
|
+
<MbUnit
|
29
|
+
Assemblies ="@(TestAssemblies)"
|
30
|
+
HaltOnFailure="false"
|
31
|
+
ReportTypes="Xml;Text;Html;Dox"
|
32
|
+
ReportFileNameFormat="mbunit-{0}-{1}"
|
33
|
+
/>
|
34
|
+
</Target>
|
35
|
+
</Project>
|
36
|
+
|
37
|
+
]]></Code>
|
38
|
+
</Snippet>
|
39
|
+
</CodeSnippet>
|
40
|
+
</CodeSnippets>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
|
3
|
+
<CodeSnippet Format="1.0.0">
|
4
|
+
<Header>
|
5
|
+
<Title>NAnt task</Title>
|
6
|
+
<Author>MbUnit</Author>
|
7
|
+
<Description>Expansion snippet for a NAnt task</Description>
|
8
|
+
<Shortcut>nant</Shortcut>
|
9
|
+
<SnippetTypes>
|
10
|
+
<SnippetType>Expansion</SnippetType>
|
11
|
+
</SnippetTypes>
|
12
|
+
</Header>
|
13
|
+
<Snippet>
|
14
|
+
<Declarations>
|
15
|
+
<Literal>
|
16
|
+
<ID>name</ID>
|
17
|
+
<ToolTip>Fixture name</ToolTip>
|
18
|
+
<Default>My</Default>
|
19
|
+
</Literal>
|
20
|
+
</Declarations>
|
21
|
+
<Code Language="XML"><![CDATA[<!-- MbUnit NAnt task definition -->
|
22
|
+
<mbunit>
|
23
|
+
<formatter type="Html"
|
24
|
+
userfile="true"
|
25
|
+
outputdir=".."
|
26
|
+
/>
|
27
|
+
<test>
|
28
|
+
$end$
|
29
|
+
</test>
|
30
|
+
</mbunit>
|
31
|
+
]]></Code>
|
32
|
+
</Snippet>
|
33
|
+
</CodeSnippet>
|
34
|
+
</CodeSnippets>
|
@@ -0,0 +1,173 @@
|
|
1
|
+
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="Perf diag template." %>
|
2
|
+
<%@ Property Name="ClassName" Type="System.String" Default="PerfCounterInfo" Category="Options" Description="ClassName." %>
|
3
|
+
<%@ Import Namespace="System.Diagnostics" %>
|
4
|
+
<%@ Import Namespace="System.Text.RegularExpressions" %>
|
5
|
+
|
6
|
+
using System;
|
7
|
+
using System.Diagnostics;
|
8
|
+
|
9
|
+
namespace MbUnit.Core.Framework
|
10
|
+
{
|
11
|
+
public class <%= ClassName %>
|
12
|
+
{
|
13
|
+
#region Constructors
|
14
|
+
private <%= ClassName %>() {}
|
15
|
+
#endregion
|
16
|
+
|
17
|
+
#region Categories
|
18
|
+
<% foreach(PerformanceCounterCategory cat in PerformanceCounterCategory.GetCategories()){
|
19
|
+
if (!this.categories.Contains(cat.CategoryName))
|
20
|
+
continue;
|
21
|
+
try
|
22
|
+
{
|
23
|
+
PerformanceCounter[] counters=null;
|
24
|
+
bool hasInstance = cat.GetInstanceNames().Length!=0;
|
25
|
+
if (!hasInstance)
|
26
|
+
counters = cat.GetCounters();
|
27
|
+
else
|
28
|
+
counters = cat.GetCounters(cat.GetInstanceNames()[0]);
|
29
|
+
foreach(PerformanceCounter counter in counters) {};
|
30
|
+
%>
|
31
|
+
#region <%= cat.CategoryName %>
|
32
|
+
/// <summary>
|
33
|
+
/// <%= cat.CategoryHelp %>
|
34
|
+
/// </summary>
|
35
|
+
public sealed class <%= GetCategoryClassName(cat) %>
|
36
|
+
{
|
37
|
+
public const string CategoryName = @"<%= cat.CategoryName %>";
|
38
|
+
#region Constructors
|
39
|
+
private <%= GetCategoryClassName(cat) %>(){}
|
40
|
+
#endregion
|
41
|
+
|
42
|
+
<%foreach(PerformanceCounter counter in counters) {%>
|
43
|
+
#region <%= counter.CounterName %>
|
44
|
+
/// <summary>
|
45
|
+
/// <%= counter.CounterHelp %>
|
46
|
+
/// </summary>
|
47
|
+
public sealed class <%= GetCounterClassName(counter)%>
|
48
|
+
{
|
49
|
+
public const string CounterName = @"<%= counter.CounterName%>";
|
50
|
+
private <%= GetCounterClassName(counter)%>(){}
|
51
|
+
<% if (hasInstance){%>
|
52
|
+
/// <summary>
|
53
|
+
/// Gets the value of the <see cref="PerformanceCounter"/>.
|
54
|
+
/// <summary>
|
55
|
+
/// <returns>
|
56
|
+
/// Value returned by <see cref="PerformanceCounter.NextValue"/>
|
57
|
+
/// for the current instance.
|
58
|
+
/// </returns>
|
59
|
+
public static float NextValue()
|
60
|
+
{
|
61
|
+
return NextValue(Process.GetCurrentProcess().ProcessName);
|
62
|
+
}
|
63
|
+
|
64
|
+
public static float NextValue(string instanceName)
|
65
|
+
{
|
66
|
+
return PerfCounterAssert.NextValue(
|
67
|
+
<%= GetCategoryClassName(cat) %>.CategoryName,
|
68
|
+
CounterName,
|
69
|
+
instanceName
|
70
|
+
);
|
71
|
+
}
|
72
|
+
<%}else{%>
|
73
|
+
/// <summary>
|
74
|
+
/// Gets the value of the <see cref="PerformanceCounter"/>.
|
75
|
+
/// <summary>
|
76
|
+
/// <returns>
|
77
|
+
/// Value returned by <see cref="PerformanceCounter.NextValue"/>.
|
78
|
+
/// </returns>
|
79
|
+
public static float NextValue()
|
80
|
+
{
|
81
|
+
return PerfCounterAssert.NextValue(
|
82
|
+
<%= GetCategoryClassName(cat) %>.CategoryName,
|
83
|
+
CounterName,
|
84
|
+
null
|
85
|
+
);
|
86
|
+
}
|
87
|
+
<%}%>
|
88
|
+
}
|
89
|
+
#endregion
|
90
|
+
<%} // GetCounters %>
|
91
|
+
}
|
92
|
+
#endregion
|
93
|
+
<%
|
94
|
+
}catch(Exception)
|
95
|
+
{}
|
96
|
+
%>
|
97
|
+
|
98
|
+
|
99
|
+
<%} // GetCategories %>
|
100
|
+
#endregion
|
101
|
+
|
102
|
+
public static float NextValue(
|
103
|
+
string categoryName,
|
104
|
+
string counterName,
|
105
|
+
string instanceName
|
106
|
+
)
|
107
|
+
{
|
108
|
+
using (PerformanceCounter counter = new PerformanceCounter(
|
109
|
+
categoryName,
|
110
|
+
counterName,
|
111
|
+
instanceName,
|
112
|
+
true)
|
113
|
+
)
|
114
|
+
{
|
115
|
+
return counter.NextValue();
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
<script runat="template">
|
122
|
+
private System.Collections.Specialized.StringCollection categories = null;
|
123
|
+
|
124
|
+
[Category("Options")]
|
125
|
+
public System.Collections.Specialized.StringCollection Categories
|
126
|
+
{
|
127
|
+
get
|
128
|
+
{
|
129
|
+
if (categories==null)
|
130
|
+
{
|
131
|
+
categories = new System.Collections.Specialized.StringCollection();
|
132
|
+
foreach(PerformanceCounterCategory cat in PerformanceCounterCategory.GetCategories()){
|
133
|
+
categories.Add(cat.CategoryName);
|
134
|
+
}
|
135
|
+
}
|
136
|
+
return categories;
|
137
|
+
}
|
138
|
+
set
|
139
|
+
{
|
140
|
+
this.categories=value;
|
141
|
+
}
|
142
|
+
}
|
143
|
+
|
144
|
+
public string Capitalize(string name)
|
145
|
+
{
|
146
|
+
return name[0] + name.Substring(1,name.Length-1);
|
147
|
+
}
|
148
|
+
public string Normalize(string name)
|
149
|
+
{
|
150
|
+
name = Regex.Replace(name,@"[A-Z]+",new System.Text.RegularExpressions.MatchEvaluator(Capit));
|
151
|
+
name = Regex.Replace(name,@"#",@"Nb");
|
152
|
+
name = Regex.Replace(name,@"\W",@"");
|
153
|
+
|
154
|
+
return name;
|
155
|
+
}
|
156
|
+
|
157
|
+
public string Capit(System.Text.RegularExpressions.Match m)
|
158
|
+
{
|
159
|
+
return m.Value[0] + m.Value.Substring(1,m.Value.Length-1).ToLower();
|
160
|
+
}
|
161
|
+
public string GetCategoryClassName(PerformanceCounterCategory cat)
|
162
|
+
{
|
163
|
+
string name = Normalize(cat.CategoryName);
|
164
|
+
|
165
|
+
return String.Format("{0}",name);
|
166
|
+
}
|
167
|
+
public string GetCounterClassName(PerformanceCounter counter)
|
168
|
+
{
|
169
|
+
string name = Normalize(counter.CounterName);
|
170
|
+
|
171
|
+
return String.Format("{0}",name);
|
172
|
+
}
|
173
|
+
</script>
|