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.
Files changed (83) hide show
  1. data/docs/ASL - Apache Software Foundation License.txt +57 -0
  2. data/docs/MbUnit License.txt +14 -0
  3. data/docs/MbUnit.chm +0 -0
  4. data/docs/Release Notes.txt +7 -0
  5. data/docs/extras/CCNet/How to use MbUnit v2 with CruiseControl.Net.txt +88 -0
  6. data/docs/extras/CCNet/images/Category.png +0 -0
  7. data/docs/extras/CCNet/images/Fixture.png +0 -0
  8. data/docs/extras/CCNet/images/Populator.png +0 -0
  9. data/docs/extras/CCNet/images/Test.png +0 -0
  10. data/docs/extras/CCNet/xsl/MBUnitDetails.xsl +592 -0
  11. data/docs/extras/CCNet/xsl/MBUnitSummary.xsl +266 -0
  12. data/docs/extras/Snippets/AdjacencyGraph.cst +1703 -0
  13. data/docs/extras/Snippets/AssertWrapper.cst +181 -0
  14. data/docs/extras/Snippets/CrudPopulator.cst +377 -0
  15. data/docs/extras/Snippets/DatabasePopulator.cst +386 -0
  16. data/docs/extras/Snippets/DatabasePopulatorCrudTest.cst +177 -0
  17. data/docs/extras/Snippets/Exception.cst +94 -0
  18. data/docs/extras/Snippets/GrammarPopulator.cst +258 -0
  19. data/docs/extras/Snippets/MockObject.cst +296 -0
  20. data/docs/extras/Snippets/RapTierCrudPopulator.cst +444 -0
  21. data/docs/extras/Snippets/SimpleFixture.cst +91 -0
  22. data/docs/extras/Snippets/SqlppCrudPopulator.cst +443 -0
  23. data/docs/extras/Snippets/TestFixture.cst +469 -0
  24. data/docs/extras/Snippets/autorunner.snippet +45 -0
  25. data/docs/extras/Snippets/combinatorialtest.snippet +54 -0
  26. data/docs/extras/Snippets/datafixture.snippet +61 -0
  27. data/docs/extras/Snippets/model.snippet +95 -0
  28. data/docs/extras/Snippets/msbuild.snippet +40 -0
  29. data/docs/extras/Snippets/nant.snippet +34 -0
  30. data/docs/extras/Snippets/perfcounterassert.cst +173 -0
  31. data/docs/extras/Snippets/processtestfixture.snippet +75 -0
  32. data/docs/extras/Snippets/rowtest.snippet +113 -0
  33. data/docs/extras/Snippets/state.snippet +27 -0
  34. data/docs/extras/Snippets/submodel.snippet +32 -0
  35. data/docs/extras/Snippets/test.snippet +28 -0
  36. data/docs/extras/Snippets/testexpectedexception.snippet +32 -0
  37. data/docs/extras/Snippets/testfixture.snippet +68 -0
  38. data/docs/extras/Snippets/testsuitefixture.snippet +48 -0
  39. data/docs/extras/Snippets/typefixture.snippet +74 -0
  40. data/docs/extras/Snippets/typefixturewithproviderfactory.snippet +77 -0
  41. data/docs/extras/Snippets/usingmbunit.snippet +19 -0
  42. data/docs/extras/Templates/VS2005/ItemTemplates/CSharp/Test/MbUnit2.TestFixtureTemplate.CSharp.zip +0 -0
  43. data/docs/extras/Templates/VS2005/ItemTemplates/VisualBasic/Test/MbUnit2.TestFixtureTemplate.VisualBasic.zip +0 -0
  44. data/docs/extras/Templates/VS2005/ProjectTemplates/CSharp/Test/MbUnit2.TestProjectTemplate.CSharp.zip +0 -0
  45. data/docs/extras/Templates/VS2005/ProjectTemplates/VisualBasic/Test/MbUnit2.TestProjectTemplate.VisualBasic.zip +0 -0
  46. data/docs/extras/Templates/VS2008/ItemTemplates/CSharp/Test/MbUnit2.TestFixtureTemplate.CSharp.zip +0 -0
  47. data/docs/extras/Templates/VS2008/ItemTemplates/VisualBasic/Test/MbUnit2.TestFixtureTemplate.VisualBasic.zip +0 -0
  48. data/docs/extras/Templates/VS2008/ProjectTemplates/CSharp/Test/MbUnit2.MvcWebApplicationTestProjectTemplate.CSharp.zip +0 -0
  49. data/docs/extras/Templates/VS2008/ProjectTemplates/CSharp/Test/MbUnit2.TestProjectTemplate.CSharp.zip +0 -0
  50. data/docs/extras/Templates/VS2008/ProjectTemplates/VisualBasic/Test/MbUnit2.MvcWebApplicationTestProjectTemplate.VisualBasic.zip +0 -0
  51. data/docs/extras/Templates/VS2008/ProjectTemplates/VisualBasic/Test/MbUnit2.TestProjectTemplate.VisualBasic.zip +0 -0
  52. data/lib/MbUnit License.txt +14 -0
  53. data/lib/MbUnit.AddIn.dll +0 -0
  54. data/lib/MbUnit.Cons.exe +0 -0
  55. data/lib/MbUnit.Cons.exe.config +12 -0
  56. data/lib/MbUnit.Framework.2.0.dll +0 -0
  57. data/lib/MbUnit.Framework.2.0.pdb +0 -0
  58. data/lib/MbUnit.Framework.2.0.xml +278 -0
  59. data/lib/MbUnit.Framework.dll +0 -0
  60. data/lib/MbUnit.Framework.pdb +0 -0
  61. data/lib/MbUnit.Framework.xml +6929 -0
  62. data/lib/MbUnit.GUI.exe +0 -0
  63. data/lib/MbUnit.GUI.exe.config +14 -0
  64. data/lib/MbUnit.MSBuild.Tasks.dll +0 -0
  65. data/lib/MbUnit.Tasks.dll +0 -0
  66. data/lib/NGraphviz.Helpers.dll +0 -0
  67. data/lib/NGraphviz.Layout.dll +0 -0
  68. data/lib/NGraphviz.dll +0 -0
  69. data/lib/QuickGraph.Algorithms.Graphviz.dll +0 -0
  70. data/lib/QuickGraph.Algorithms.dll +0 -0
  71. data/lib/QuickGraph.Algorithms.pdb +0 -0
  72. data/lib/QuickGraph.Algorithms.xml +2818 -0
  73. data/lib/QuickGraph.dll +0 -0
  74. data/lib/QuickGraph.pdb +0 -0
  75. data/lib/QuickGraph.xml +3126 -0
  76. data/lib/Refly.dll +0 -0
  77. data/lib/Refly.pdb +0 -0
  78. data/lib/Refly.xml +1327 -0
  79. data/lib/TestFu.dll +0 -0
  80. data/lib/TestFu.pdb +0 -0
  81. data/lib/TestFu.xml +1932 -0
  82. data/lib/XsdTidy.exe +0 -0
  83. metadata +163 -0
@@ -0,0 +1,94 @@
1
+ <%@ CodeTemplate Language="C#" TargetLanguage="Text" Description="Template description here." %>
2
+ <%@ Property Name="ClassName" Type="System.String" Category="Options" Description="Class name." Optional="False"%>
3
+ <%@ Property Name="MessageFormat" Type="System.String" Category="Options" Description="Message format string" Optional="False" %>
4
+ // QuickGraph Library
5
+ //
6
+ // Copyright (c) 2004 Jonathan de Halleux
7
+ //
8
+ // This software is provided 'as-is', without any express or implied warranty.
9
+ //
10
+ // In no event will the authors be held liable for any damages arising from
11
+ // the use of this software.
12
+ // Permission is granted to anyone to use this software for any purpose,
13
+ // including commercial applications, and to alter it and redistribute it
14
+ // freely, subject to the following restrictions:
15
+ //
16
+ // 1. The origin of this software must not be misrepresented;
17
+ // you must not claim that you wrote the original software.
18
+ // If you use this software in a product, an acknowledgment in the product
19
+ // documentation would be appreciated but is not required.
20
+ //
21
+ // 2. Altered source versions must be plainly marked as such, and must
22
+ // not be misrepresented as being the original software.
23
+ //
24
+ // 3. This notice may not be removed or altered from any source
25
+ // distribution.
26
+ //
27
+ // QuickGraph Library HomePage: http://mbunit.tigris.org
28
+ // Author: Jonathan de Halleux
29
+
30
+
31
+ using System;
32
+ using System.Runtime.Serialization;
33
+ using System.IO;
34
+
35
+ namespace QuickGraph.Exceptions
36
+ {
37
+ /// <summary>
38
+ /// Exception throwed when not finding a vertex.
39
+ /// </summary>
40
+ [Serializable]
41
+ public class <%= FullClassName %> : Exception
42
+ {
43
+ public <%= FullClassName %>(String message)
44
+ : base(message)
45
+ {}
46
+
47
+ /// <summary>
48
+ /// Constructs an empty exception
49
+ /// </summary>
50
+ public <%= FullClassName %>()
51
+ :base()
52
+ {}
53
+
54
+ /// <summary>
55
+ /// Creates an exception with a message
56
+ /// and an inner exception.
57
+ /// </summary>
58
+ /// <param name="message">Error message</param>
59
+ /// <param name="ex">Inner exception</param>
60
+ public <%= FullClassName %>(String message, Exception ex)
61
+ :base(message,ex)
62
+ {}
63
+
64
+ /// <summary>
65
+ ///
66
+ /// </summary>
67
+ /// <param name="info"></param>
68
+ /// <param name="ctx"></param>
69
+ protected <%= FullClassName %>(SerializationInfo info, StreamingContext ctx)
70
+ :base(info,ctx)
71
+ {}
72
+
73
+ /// <summary>
74
+ ///
75
+ /// </summary>
76
+ /// <returns></returns>
77
+ public override string Message
78
+ {
79
+ get
80
+ {
81
+ return String.Format("<%= MessageFormat %>",base.Message);
82
+ }
83
+ }
84
+ }
85
+ }
86
+ <script runat="template">
87
+ protected string FullClassName
88
+ {
89
+ get
90
+ {
91
+ return this.ClassName + "Exception";
92
+ }
93
+ }
94
+ </script>
@@ -0,0 +1,258 @@
1
+ <%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="TestFu Grammar" %>
2
+ <%@ Property Name="Namespace" Type="System.String"
3
+ Default="Populators"
4
+ Category="Output"
5
+ Description="Namespace of the populator." %>
6
+ <%@ Property Name="DataSetNameFormat" Type="System.String"
7
+ Default="{0}DataSet"
8
+ Category="Output"
9
+ Description="Format string to create the DatabaseSet class name." %>
10
+ <%@ Property Name="CrudPopulatorNameFormat" Type="System.String"
11
+ Default="{0}CrudPopulator"
12
+ Category="Output"
13
+ Description="Format string to create the CrudPopulator class name." %>
14
+ <%@ Property Name="DatabasePopulatorNameFormat" Type="System.String"
15
+ Default="{0}DatabasePopulator"
16
+ Category="Output"
17
+ Description="Format string to create the DatabasePopulator class name." %>
18
+ <%@ Property Name="GrammarNameFormat" Type="System.String"
19
+ Default="{0}Grammar"
20
+ Category="Output"
21
+ Description="Format string to create the Grammar class name." %>
22
+ <%@ Property Name="TableNamePrefix" Type="System.String"
23
+ Default=""
24
+ Category="Output"
25
+ Optional="true"
26
+ Description="Prefix to be removed." %>
27
+ <%@ Property Name="TablePopulatorNameFormat" Type="System.String"
28
+ Default="{0}TablePopulator"
29
+ Category="Output"
30
+ Description="Format string to create the TablePopulator class names." %>
31
+ <%@ Property Name="ColumnDataGeneratorNameFormat" Type="System.String"
32
+ Default="{0}DataGenerator"
33
+ Category="Output"
34
+ Description="Format string to create the ColumnGenenerator properties." %>
35
+ <%@ Property Name="UniqueValidatorNameFormat" Type="System.String"
36
+ Default="{0}Validator"
37
+ Category="Output"
38
+ Description="Format string to create the UniqueValidator properties." %>
39
+ <%@ Property Name="ForeignKeyProviderNameFormat" Type="System.String"
40
+ Default="{0}Provider"
41
+ Category="Output"
42
+ Description="Format string to create the ForeignKeyProviderNameFormat properties." %>
43
+ <%@ Property Name="Database" Type="SchemaExplorer.DatabaseSchema"
44
+ Category="Context"
45
+ Description="Target database for the IDatabasePopulator." %>
46
+ <%@ Assembly Name="SchemaExplorer" %>
47
+ <%@ Import Namespace="SchemaExplorer" %>
48
+ //////////////////////////////////////////////////////////////////
49
+ //
50
+ // Strongly typed CRUD populator for the <%= DatabaseName %>
51
+ //
52
+ // This file was generated by CodeSmith. Do not edit it! Modify
53
+ // the template if you need to tweak it for you.
54
+ //
55
+ //////////////////////////////////////////////////////////////////
56
+
57
+ using System;
58
+ using System.Data;
59
+ using System.Data.SqlClient;
60
+
61
+ using MbUnit.Core.Framework;
62
+ using MbUnit.Framework;
63
+
64
+ using TestFu.Data;
65
+ using TestFu.Data.SqlClient;
66
+ using TestFu.Data.Graph;
67
+ using TestFu.Grammars;
68
+
69
+ namespace <%= Namespace %>
70
+ {
71
+ /// <summary>
72
+ /// A strongly-typed <see cref="IGrammar"/> for the
73
+ /// <em><%= DatabaseName %> database.
74
+ /// </summary>
75
+ public class <%= DatabaseGrammarName %> : Grammar
76
+ {
77
+ #region Fields
78
+ private <%= CrudPopulatorName%> populator;
79
+ <% foreach(TableSchema table in this.Database.Tables) { %>
80
+ private <%= TableGrammarName(table) %> <%= FormatLower(TableGrammarPropertyName(table)) %>;
81
+ <%}// foreach(TableSchema table in this.Database.Tables) %>
82
+ #endregion
83
+
84
+ #region Constructors
85
+ /// <summary>
86
+ /// Initializes a new <see cref="<%= DatabaseGrammarName %>"/> instance
87
+ /// with a <see cref="<%= CrudPopulatorName%>"/> instance.
88
+ /// </summary>
89
+ public <%= DatabaseGrammarName %>(<%= CrudPopulatorName%> populator)
90
+ {
91
+ if (populator==null)
92
+ throw new ArgumentNullException("populator");
93
+ this.populator = populator;
94
+
95
+ AlternativeRule alt = new AlternativeRule();
96
+ <% foreach(TableSchema table in this.Database.Tables) { %>
97
+ <%= FormatLower(TableGrammarPropertyName(table))%> = new <%= TableGrammarName(table) %>(populator);
98
+ alt.Rules.Add(<%= FormatLower(TableGrammarPropertyName(table))%>);
99
+ <%}// foreach(TableSchema table in this.Database.Tables) %>
100
+ this.StartRule = Rules.Kleene(alt);
101
+ }
102
+ #endregion
103
+
104
+ #region Grammars
105
+ <% foreach(TableSchema table in this.Database.Tables) { %>
106
+ <%= TableGrammarName(table) %> <%= TableGrammarPropertyName(table) %>
107
+ {
108
+ get { return <%= FormatLower(TableGrammarPropertyName(table)) %>;}
109
+ }
110
+ <% } // %>
111
+ #endregion
112
+
113
+ #region Grammars Classes
114
+ <% foreach(TableSchema table in this.Database.Tables) { %>
115
+ #region <%= table.Name %>
116
+ public class <%= TableGrammarName(table) %> : Grammar
117
+ {
118
+ private <%= CrudPopulatorName%> populator;
119
+ private IRule createRule;
120
+ private IRule updateRule;
121
+ private IRule deleteRule;
122
+
123
+ public <%= TableGrammarName(table) %>(<%= CrudPopulatorName%> populator)
124
+ {
125
+ if (populator==null)
126
+ throw new ArgumentNullException("populator");
127
+ this.populator = populator;
128
+ this.CreateRules();
129
+ }
130
+
131
+ public <%= CrudPopulatorName%> Populator
132
+ {
133
+ get { return this.populator;}
134
+ }
135
+
136
+ public IRule CreateRule
137
+ {
138
+ get { return this.createRule;}
139
+ }
140
+ public IRule UpdateRule
141
+ {
142
+ get { return this.updateRule;}
143
+ }
144
+ public IRule DeleteRule
145
+ {
146
+ get { return this.deleteRule;}
147
+ }
148
+
149
+ protected void CreateRules()
150
+ {
151
+ this.createRule = Rules.Method(new MethodInvoker(this.Create));
152
+ this.updateRule = Rules.Method(new MethodInvoker(this.Update));
153
+ this.deleteRule = Rules.Method(new MethodInvoker(this.Delete));
154
+
155
+ this.StartRule = Rules.Alt(
156
+ this.createRule
157
+ ,this.updateRule
158
+ // ,this.deleteRule
159
+ );
160
+ }
161
+
162
+ private void Create()
163
+ {
164
+ DataRow row = this.populator.Create<%= Format(table.Name) %>();
165
+ Console.WriteLine("Created <%= Format(table.Name) %>");
166
+ }
167
+ private void Delete()
168
+ {
169
+ this.populator.Delete<%= Format(table.Name) %>();
170
+ Console.WriteLine("Deleted <%= Format(table.Name) %>");
171
+ }
172
+ private void Update()
173
+ {
174
+ this.populator.Update<%= Format(table.Name) %>();
175
+ Console.WriteLine("Updated <%= Format(table.Name) %>");
176
+ }
177
+ }
178
+ #endregion
179
+ <%}// foreach(TableSchema table in this.Database.Tables) %>
180
+ #endregion
181
+ }
182
+ }
183
+ <script runat="template">
184
+ #region Properties
185
+ public string DatabaseName
186
+ {
187
+ get
188
+ {
189
+ return this.Database.Name;
190
+ }
191
+ }
192
+ public string DatabaseGrammarName
193
+ {
194
+ get
195
+ {
196
+ return Format(this.GrammarNameFormat,this.DatabaseName);
197
+ }
198
+ }
199
+ public string TableGrammarName(TableSchema table)
200
+ {
201
+ return Format(this.GrammarNameFormat, table.Name);
202
+ }
203
+ public string TableGrammarPropertyName(TableSchema table)
204
+ {
205
+ return Format(table.Name);
206
+ }
207
+ public string DataSetName
208
+ {
209
+ get{ return Format(this.DataSetNameFormat, this.DatabaseName);}
210
+ }
211
+ public string CrudPopulatorName
212
+ {
213
+ get{ return Format(this.CrudPopulatorNameFormat,this.DatabaseName);}
214
+ }
215
+ public string DatabasePopulatorName
216
+ {
217
+ get{ return Format(this.DatabasePopulatorNameFormat,this.DatabaseName);}
218
+ }
219
+ public string GetTablePopulatorName(TableSchema table)
220
+ {
221
+ return Format(this.TablePopulatorNameFormat, table.Name);
222
+ }
223
+ public string GetTablePopulatorPropertyName(TableSchema table)
224
+ {
225
+ return Format(table.Name);
226
+ }
227
+ public string GetColumnDataGeneratorName(ColumnSchema column)
228
+ {
229
+ return Format(ColumnDataGeneratorNameFormat, column.Name);
230
+ }
231
+ public string GetUniqueValidatorName(TableKeySchema unique)
232
+ {
233
+ return Format(UniqueValidatorNameFormat, unique.Name);
234
+ }
235
+ public string GetForeignKeyProviderName(TableKeySchema unique)
236
+ {
237
+ return Format(ForeignKeyProviderNameFormat, unique.Name);
238
+ }
239
+ protected string FormatLower(string format, params object[] args)
240
+ {
241
+ string s= Format(format,args);
242
+ return Char.ToLower(s[0]) + s.Substring(1);
243
+ }
244
+ protected string Format(string format, params Object[] args)
245
+ {
246
+ string result = string.Format(format,args);
247
+ if (this.TableNamePrefix!=null && this.TableNamePrefix.Length > 0)
248
+ {
249
+ if (result.StartsWith(this.TableNamePrefix))
250
+ result = result.Substring(this.TableNamePrefix.Length);
251
+ }
252
+
253
+ result = result.Replace(" ","").Replace("_","").Replace(".","");
254
+ return result;
255
+ }
256
+
257
+ #endregion
258
+ </script>
@@ -0,0 +1,296 @@
1
+ <%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="Basic Mock Object template." %>
2
+ <%@ Property Name="Interface" Type="System.String" Category="Options" Description="Interface to mock" %>
3
+ <%@ Property Name="Namespace" Type="System.String" Category="Options" Description="Namespace of the wrapped class" %>
4
+ <%@ Property Name="MockNamespace" Type="System.String" Category="Options" Description="Namespace of the wrapped class" %>
5
+ <%@ Import Namespace="System.Reflection" %>
6
+ <%@ Import Namespace="System.Collections" %>
7
+ <%@ Import Namespace="System.Collections.Specialized" %>
8
+ <%@ Import Namespace="System.IO" %>
9
+ <%@ Import Namespace="System.ComponentModel.Design" %>
10
+ <%@ Import Namespace="System.Drawing.Design" %>
11
+ <%@ Assembly Name="AssemblyHelper"%>
12
+ <%@ Assembly Name="System.Design"%>
13
+ <%@ Import Namespace="AssemblyHelper" %>
14
+
15
+ using System;
16
+ using DotNetMock;
17
+ using <%= Namespace %>
18
+
19
+ namespace <%= MockNamespace %>
20
+ {
21
+ /// <summary>
22
+ /// Mock of the <%= SeeInterface %> interface.
23
+ /// </summary>
24
+ /// <remark>
25
+ /// This class was generated and needs some work :)
26
+ /// </remarks>
27
+ public class <%= MockClass %> : <%= Interface %>, MockObject
28
+ {
29
+ #region Private fields
30
+ <% foreach(ExpectationEntry ep in this.expectations){%>
31
+ private <%= ep.ExpectedType %> <%= ep.FieldName %> = new <%= ep.ExpectedType %>("<%= MockClass %>.<%= ep.Name %>");
32
+ <%}%>
33
+ #endregion
34
+
35
+ #region MockObject
36
+ /// <summary>
37
+ /// Default Constructor
38
+ /// </summary>
39
+ public <%= MockClass %>() {}
40
+
41
+ /// <summary>
42
+ /// Constructor. Sets the name of this <see cref="<%= MockClass %>"/>
43
+ /// </summary>
44
+ /// <param name="name">Name of this MockObject</param>
45
+ public <%= MockClass %>(string name)
46
+ :base(name)
47
+ {}
48
+
49
+ <% foreach(ExpectationEntry ep in this.expectations){%>
50
+ /// <summary>
51
+ /// Sets the ... affected
52
+ /// </summary>
53
+ /// <param name="expected">
54
+ /// Expected value.
55
+ /// </param>
56
+ public void <%= ep.MethodName() %>(<%= ep.ValueType %> expected)
57
+ {
58
+ this.<%= ep.Name %>.Expected = expected;
59
+ this.NotImplemented("Set<%= ep.MethodName() %>");
60
+ }
61
+ <%}%>
62
+
63
+ #endregion
64
+
65
+ #region <%= Interface %> members
66
+ <% foreach(MethodInfo mi in this.InterfaceType.GetMethods()){
67
+ if (mi.Name.StartsWith("get_") || mi.Name.StartsWith("set_"))
68
+ continue;
69
+ %>
70
+ <%= mi.ReturnType %> <%= this.InterfaceType.Name %>.<%= mi.Name %>(<%= MethodParameters(mi) %>)
71
+ {
72
+ this.NotImplemented("<%= mi.Name %>");
73
+ }
74
+
75
+ <% }%>
76
+ <% foreach(PropertyInfo pi in this.InterfaceType.GetProperties()){%>
77
+ <%= pi.PropertyType %> <%= this.InterfaceType.Name %>.<%= pi.Name %><%= PropertyParameters(pi) %>
78
+ {
79
+ <% if (pi.CanRead){%>
80
+ get
81
+ {
82
+ this.NotImplemented("get <%= pi.Name %>");
83
+ }
84
+ <% }
85
+ if (pi.CanWrite){%>
86
+ get
87
+ {
88
+ this.NotImplemented("set <%= pi.Name %>");
89
+ }
90
+ <% }%>
91
+ }
92
+
93
+ <% }%>
94
+ #endregion
95
+
96
+ <% foreach(Type it in this.InterfaceType.GetInterfaces()) {%>
97
+ #region <%= it.Name %> members
98
+ <% foreach(MethodInfo mi in it.GetMethods()){
99
+ if (mi.Name.StartsWith("get_") || mi.Name.StartsWith("set_"))
100
+ continue;
101
+ %>
102
+ <%= mi.ReturnType %> <%= it.Name %>.<%= mi.Name %>(<%= MethodParameters(mi) %>)
103
+ {
104
+ this.NotImplemented("<%= mi.Name %>");
105
+ }
106
+
107
+ <% }%>
108
+ <% foreach(PropertyInfo pi in it.GetProperties()){%>
109
+ <%= pi.PropertyType %> <%= it.Name %>.<%= pi.Name %><%= PropertyParameters(pi) %>
110
+ {
111
+ <% if (pi.CanRead){%>
112
+ get
113
+ {
114
+ this.NotImplemented("get <%= pi.Name %>");
115
+ }
116
+ <% }
117
+ if (pi.CanWrite){%>
118
+ get
119
+ {
120
+ this.NotImplemented("set <%= pi.Name %>");
121
+ }
122
+ <% }%>
123
+ }
124
+
125
+ <% }%>
126
+ #endregion
127
+ <%}%>
128
+ }
129
+ }
130
+
131
+ <script runat="template">
132
+ private Assembly assembly;
133
+ private ExpectationEntryCollection expectations = new ExpectationEntryCollection();
134
+
135
+ [Editor(typeof(AssemblyHelper.AssemblyFilePicker), typeof(System.Drawing.Design.UITypeEditor))]
136
+ [Category("Options")]
137
+ public Assembly AssemblyToLoad
138
+ {
139
+ get{return assembly;}
140
+ set{assembly = value;}
141
+ }
142
+
143
+ [TypeConverter(typeof(ExpandableObjectConverter))]
144
+ [Category("Options")]
145
+ public class ExpectationEntry
146
+ {
147
+ private string expectedType;
148
+ private string fieldName;
149
+ private string name;
150
+ private string value;
151
+ private string valueType;
152
+
153
+ [Category("Options")]
154
+ public String ExpectedType
155
+ {
156
+ get{ return this.expectedType;}
157
+ set{ this.expectedType = value;}
158
+ }
159
+ [Category("Options")]
160
+ public String FieldName
161
+ {
162
+ get{ return this.fieldName;}
163
+ set{ this.fieldName = value;}
164
+ }
165
+ [Category("Options")]
166
+ public String Name
167
+ {
168
+ get{ return this.name;}
169
+ set{ this.name = value;}
170
+ }
171
+ [Category("Options")]
172
+ public String Value
173
+ {
174
+ get{ return this.value;}
175
+ set{ this.value = value;}
176
+ }
177
+ [Category("Options")]
178
+ public String ValueType
179
+ {
180
+ get{ return this.valueType;}
181
+ set{ this.valueType = value;}
182
+ }
183
+ public Type GetExpectationType()
184
+ {
185
+ return System.Type.GetType(this.expectedType, true);
186
+ }
187
+ public Type GetValueType()
188
+ {
189
+ return System.Type.GetType(this.valueType, true);
190
+ }
191
+ public String ValueToString()
192
+ {
193
+ if (GetValueType()== typeof(String))
194
+ return String.Format("\"{0}\"", this.Value);
195
+ else
196
+ return this.Value.ToString();
197
+ }
198
+ public String MethodName()
199
+ {
200
+ return "See" + Char.ToUpper(fieldName[0]) + fieldName.Substring(1, fieldName.Length-1);
201
+ }
202
+ }
203
+
204
+ public class ExpectationEntryCollection : ArrayList
205
+ {
206
+ public new ExpectationEntry this[int index]
207
+ {
208
+ get
209
+ {
210
+ return (ExpectationEntry)base[index];
211
+ }
212
+ set
213
+ {
214
+ base[index] = value;
215
+ }
216
+ }
217
+ }
218
+
219
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
220
+ [Editor(typeof(CollectionEditor), typeof(System.Drawing.Design.UITypeEditor))]
221
+ [Category("Options")]
222
+ public ExpectationEntryCollection Expectations
223
+ {
224
+ get{return expectations;}
225
+ set{expectations = value;}
226
+ }
227
+
228
+ // fields
229
+ private Type interfaceType = null;
230
+ // mocked class type
231
+ protected Type InterfaceType
232
+ {
233
+ get
234
+ {
235
+ if (this.interfaceType==null)
236
+ {
237
+ this.interfaceType=this.AssemblyToLoad.GetType(
238
+ String.Format("{0}.{1}",
239
+ this.Namespace,this.Interface),
240
+ true);
241
+ if (!this.interfaceType.IsInterface)
242
+ throw new Exception("Type must be an interface");
243
+ }
244
+ return this.interfaceType;
245
+ }
246
+ }
247
+ // <see cref="Interface"/>
248
+ protected string SeeInterface
249
+ {
250
+ get
251
+ {
252
+ return String.Format("<see cref=\"{0}\"/>", this.Interface);
253
+ }
254
+ }
255
+ // mock class name
256
+ protected string MockClass
257
+ {
258
+ get
259
+ {
260
+ return "Mock" + this.Interface.Substring(1, this.Interface.Length-1);
261
+ }
262
+ }
263
+ // output parameters to string
264
+ protected string MethodParameters(MethodBase mi)
265
+ {
266
+ StringWriter sw = new StringWriter();
267
+ bool comma = false;
268
+ foreach(ParameterInfo pi in mi.GetParameters())
269
+ {
270
+ if (comma)
271
+ sw.Write(", ");
272
+ else
273
+ comma=true;
274
+
275
+ sw.Write("{0} {1}",pi.ParameterType.Name, pi.Name);
276
+ }
277
+ return sw.ToString();
278
+ }
279
+ protected string PropertyParameters(PropertyInfo pi)
280
+ {
281
+ if (pi.CanRead)
282
+ {
283
+ if (pi.GetGetMethod().GetParameters().Length==0)
284
+ return null;
285
+ else
286
+ return String.Format("[{0}]",this.MethodParameters(pi.GetGetMethod()));
287
+ }
288
+ else
289
+ {
290
+ if (pi.GetSetMethod().GetParameters().Length==0)
291
+ return null;
292
+ else
293
+ return String.Format("[{0}]",this.MethodParameters(pi.GetSetMethod()));
294
+ }
295
+ }
296
+ </script>