mbunit2 2.4.2.355.20100801
Sign up to get free protection for your applications and to get access to all the features.
- 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,444 @@
|
|
1
|
+
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="TestFu DatabasePopulator Crud Harness" %>
|
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="DalNamespace" Type="System.String"
|
11
|
+
Default="Northwind"
|
12
|
+
Category="Output"
|
13
|
+
Description="Namespace of the Dal" %>
|
14
|
+
<%@ Property Name="DalFormatName" Type="System.String"
|
15
|
+
Default="{0}"
|
16
|
+
Category="Output"
|
17
|
+
Description="Format string to create the Dal class name" %>
|
18
|
+
<%@ Property Name="CrudPopulatorNameFormat" Type="System.String"
|
19
|
+
Default="{0}CrudPopulator"
|
20
|
+
Category="Output"
|
21
|
+
Description="Format string to create the CrudPopulator class name." %>
|
22
|
+
<%@ Property Name="DatabasePopulatorNameFormat" Type="System.String"
|
23
|
+
Default="{0}DatabasePopulator"
|
24
|
+
Category="Output"
|
25
|
+
Description="Format string to create the DatabasePopulator class name." %>
|
26
|
+
<%@ Property Name="TableNamePrefix" Type="System.String"
|
27
|
+
Default=""
|
28
|
+
Category="Output"
|
29
|
+
Optional="true"
|
30
|
+
Description="Prefix to be removed." %>
|
31
|
+
<%@ Property Name="TablePopulatorNameFormat" Type="System.String"
|
32
|
+
Default="{0}TablePopulator"
|
33
|
+
Category="Output"
|
34
|
+
Description="Format string to create the TablePopulator class names." %>
|
35
|
+
<%@ Property Name="ColumnDataGeneratorNameFormat" Type="System.String"
|
36
|
+
Default="{0}DataGenerator"
|
37
|
+
Category="Output"
|
38
|
+
Description="Format string to create the ColumnGenenerator properties." %>
|
39
|
+
<%@ Property Name="UniqueValidatorNameFormat" Type="System.String"
|
40
|
+
Default="{0}Validator"
|
41
|
+
Category="Output"
|
42
|
+
Description="Format string to create the UniqueValidator properties." %>
|
43
|
+
<%@ Property Name="ForeignKeyProviderNameFormat" Type="System.String"
|
44
|
+
Default="{0}Provider"
|
45
|
+
Category="Output"
|
46
|
+
Description="Format string to create the ForeignKeyProviderNameFormat properties." %>
|
47
|
+
<%@ Property Name="Database" Type="SchemaExplorer.DatabaseSchema"
|
48
|
+
Category="Context"
|
49
|
+
Description="Target database for the IDatabasePopulator." %>
|
50
|
+
<%@ Assembly Name="SchemaExplorer" %>
|
51
|
+
<%@ Import Namespace="SchemaExplorer" %>
|
52
|
+
//////////////////////////////////////////////////////////////////
|
53
|
+
//
|
54
|
+
// Strongly typed CRUD populator for the <%= DatabaseName %>
|
55
|
+
//
|
56
|
+
// This file was generated by CodeSmith. Do not edit it! Modify
|
57
|
+
// the template if you need to tweak it for you.
|
58
|
+
//
|
59
|
+
//////////////////////////////////////////////////////////////////
|
60
|
+
|
61
|
+
using System;
|
62
|
+
using System.Data;
|
63
|
+
using System.Data.SqlClient;
|
64
|
+
using System.Data.SqlTypes;
|
65
|
+
|
66
|
+
using MbUnit.Core.Framework;
|
67
|
+
using MbUnit.Framework;
|
68
|
+
|
69
|
+
using TestFu.Data;
|
70
|
+
using TestFu.Data.SqlClient;
|
71
|
+
using TestFu.Data.Graph;
|
72
|
+
|
73
|
+
using <%= DalNamespace %>;
|
74
|
+
|
75
|
+
namespace <%= Namespace %>
|
76
|
+
{
|
77
|
+
/// <summary>
|
78
|
+
/// A CRUD harness for the <%= DatabaseName %> database.
|
79
|
+
/// </summary>
|
80
|
+
/// <remarks>
|
81
|
+
/// <para><b>Note to implementors:</b></para>
|
82
|
+
/// <para>
|
83
|
+
/// Implementors should modify the CodeSmith template that generated
|
84
|
+
/// this class to inject their Create,Update,Read and Delete methods.
|
85
|
+
/// Each generated method contains a <see cref="NotImplementedException"/>
|
86
|
+
/// that should be replaced with the proper DAL code.
|
87
|
+
/// </para>
|
88
|
+
/// <para>
|
89
|
+
/// The <c>Create*</c> methods create a new row and verify that it is
|
90
|
+
/// present in the database using the <c>Read*</c> methods.
|
91
|
+
/// The <c>Update*</c> methods apply an update between two rows and
|
92
|
+
/// verify that the update was succesful using <c>Read*</c> methods.
|
93
|
+
/// The <c>Delete*</c> remove a row from the tables and verify
|
94
|
+
/// that it has been removed using <c>Read*</c> methods.
|
95
|
+
/// </para>
|
96
|
+
/// <remarks>
|
97
|
+
public class <%= CrudPopulatorName %> : <%= DatabasePopulatorName %>
|
98
|
+
{
|
99
|
+
#region Fields
|
100
|
+
private <%= DalNamespace %>.<%= Format(DalFormatName, DatabaseName) %> dal = new <%= DalNamespace %>.<%= Format(DalFormatName, DatabaseName) %>();
|
101
|
+
#endregion
|
102
|
+
#region Constructors
|
103
|
+
/// <summary>
|
104
|
+
/// Initializes a new <see cref="<%= CrudPopulatorName %>"/> with the
|
105
|
+
/// connection string of the database.
|
106
|
+
/// </summary>
|
107
|
+
/// <param name="connectionString">
|
108
|
+
/// A valid conneciton string to the target database.
|
109
|
+
/// </param>
|
110
|
+
/// <exception type="ArgumentNullException">
|
111
|
+
/// The <paramref name="connectionString"/> is a
|
112
|
+
/// null reference (Nothing in Visual Basic).
|
113
|
+
/// </exception>
|
114
|
+
/// <exception type="ArgumentException">
|
115
|
+
/// The <paramref name="connectionString"/> is empty.
|
116
|
+
/// </exception>
|
117
|
+
public <%= CrudPopulatorName %>(string connectionString)
|
118
|
+
:this(new <%= DataSetName %>(), connectionString)
|
119
|
+
{}
|
120
|
+
|
121
|
+
/// <summary>
|
122
|
+
/// Initializes a new <see cref="<%= CrudPopulatorName %>"/> with the
|
123
|
+
/// connection string of the database.
|
124
|
+
/// </summary>
|
125
|
+
/// <param name="dataSet">
|
126
|
+
/// A <see cref="DataSet"/> representing the structure of the
|
127
|
+
/// <em><%= DatabaseName %></em> database.
|
128
|
+
/// </param>
|
129
|
+
/// <param name="connectionString">
|
130
|
+
/// A valid conneciton string to the target database.
|
131
|
+
/// </param>
|
132
|
+
/// <exception type="ArgumentNullException">
|
133
|
+
/// The <paramref name="dataSet"/> or the <paramref name="connectionString"/> is a
|
134
|
+
/// null reference (Nothing in Visual Basic).
|
135
|
+
/// </exception>
|
136
|
+
/// <exception type="ArgumentException">
|
137
|
+
/// The <paramref name="connectionString"/> is empty.
|
138
|
+
/// </exception>
|
139
|
+
public <%= CrudPopulatorName %>(
|
140
|
+
DataSet dataSet,
|
141
|
+
string connectionString
|
142
|
+
)
|
143
|
+
:base(dataSet,connectionString)
|
144
|
+
{}
|
145
|
+
#endregion
|
146
|
+
|
147
|
+
<% foreach(TableSchema table in this.Database.Tables) {%>
|
148
|
+
#region <%= table.Name %>
|
149
|
+
/// <summary>
|
150
|
+
/// Creates a new <see cref="DataRow"/> in the
|
151
|
+
/// <em><%= table.Name %> table.
|
152
|
+
/// </summary>
|
153
|
+
/// <returns>
|
154
|
+
/// The created <see cref="DataRow"/> instance
|
155
|
+
/// </returns>
|
156
|
+
public virtual DataRow Create<%= Format(table.Name) %>()
|
157
|
+
{
|
158
|
+
// generate row
|
159
|
+
DataRow row = this.<%=GetTablePopulatorPropertyName(table)%>.Generate();
|
160
|
+
|
161
|
+
// Add the row to the <%= table.Name %> table here
|
162
|
+
<%= TableRow(table) %> irow = new <%= TableRow(table) %>();
|
163
|
+
<% foreach(ColumnSchema column in table.Columns) {%>
|
164
|
+
<% if (column.AllowDBNull) {%>
|
165
|
+
if (row["<%= column.Name%>"] is DBNull)
|
166
|
+
<% if (column.SystemType.IsValueType) {%>
|
167
|
+
irow.Is<%= Format(column.Name) %>Null = true;
|
168
|
+
<% } else { %>
|
169
|
+
irow.<%= Format(column.Name) %> = null;
|
170
|
+
<%}%>
|
171
|
+
else
|
172
|
+
irow.<%= Format(column.Name) %> = (<%= column.SystemType %>)row["<%= column.Name %>"];
|
173
|
+
<% } else {%>
|
174
|
+
irow.<%= Format(column.Name) %> = (<%= column.SystemType %>)row["<%= column.Name %>"];
|
175
|
+
<% } %>
|
176
|
+
<% } // foreach(ColumnSchema column in table.Columns) %>
|
177
|
+
|
178
|
+
try
|
179
|
+
{
|
180
|
+
this.dal.<%= TableCollection(table) %>.Insert(irow);
|
181
|
+
}
|
182
|
+
catch(Exception ex)
|
183
|
+
{
|
184
|
+
Console.WriteLine("Inserted row:");
|
185
|
+
DisplayRow(row);
|
186
|
+
throw new ApplicationException("Insertion in <%= table.Name %> failed",ex);
|
187
|
+
}
|
188
|
+
|
189
|
+
|
190
|
+
// RapTier does not return the new identity when the primary key is
|
191
|
+
// identity. Hence, we cannot verify anything!
|
192
|
+
|
193
|
+
return row;
|
194
|
+
}
|
195
|
+
|
196
|
+
<% if (table.PrimaryKey.MemberColumns.Count != table.Columns.Count) {%>
|
197
|
+
/// <summary>
|
198
|
+
/// Updates a row (chosen randomly) with a new generated row in the
|
199
|
+
/// <em><%= table.Name %> table.
|
200
|
+
/// </summary>
|
201
|
+
/// <returns>
|
202
|
+
/// The update <see cref="DataRow"/> instance
|
203
|
+
/// </returns>
|
204
|
+
public virtual DataRow Update<%= Format(table.Name) %>()
|
205
|
+
{
|
206
|
+
// generate row
|
207
|
+
DataRow row = this.<%=GetTablePopulatorPropertyName(table)%>.GetRandomRow();
|
208
|
+
// update random
|
209
|
+
return Update<%= Format(table.Name) %>(row);
|
210
|
+
}
|
211
|
+
|
212
|
+
/// <summary>
|
213
|
+
/// Updates <paramref name="row"/> with <paramref name="rowToUpdate"/> in the
|
214
|
+
/// <em><%= table.Name %> table.
|
215
|
+
/// </summary>
|
216
|
+
/// <returns>
|
217
|
+
/// The update <see cref="DataRow"/> instance
|
218
|
+
/// </returns>
|
219
|
+
public virtual DataRow Update<%= Format(table.Name) %>(DataRow row)
|
220
|
+
{
|
221
|
+
if (row==null)
|
222
|
+
throw new ArgumentNullException("row");
|
223
|
+
|
224
|
+
// changes values
|
225
|
+
this.<%= GetTablePopulatorPropertyName(table)%>.ChangeRowValues(row);
|
226
|
+
|
227
|
+
// Update the rowToUpdate with row in the <%= table.Name %> table
|
228
|
+
<%= TableRow(table) %> urow = new <%= TableRow(table) %>();
|
229
|
+
<% foreach(ColumnSchema column in table.Columns) {%>
|
230
|
+
<% if (column.AllowDBNull) {%>
|
231
|
+
if (row["<%= column.Name%>"] is DBNull)
|
232
|
+
<% if (column.SystemType.IsValueType) {%>
|
233
|
+
urow.Is<%= Format(column.Name) %>Null = true;
|
234
|
+
<% } else { %>
|
235
|
+
urow.<%= Format(column.Name) %> = null;
|
236
|
+
<%}%>
|
237
|
+
else
|
238
|
+
urow.<%= Format(column.Name) %> = (<%= column.SystemType %>)row["<%= column.Name %>"];
|
239
|
+
<% } else {%>
|
240
|
+
urow.<%= Format(column.Name) %> = (<%= column.SystemType %>)row["<%= column.Name %>"];
|
241
|
+
<% } %>
|
242
|
+
<% } // foreach(ColumnSchema column in table.Columns) %>
|
243
|
+
try
|
244
|
+
{
|
245
|
+
this.dal.<%= TableCollection(table) %>.Update(urow);
|
246
|
+
}
|
247
|
+
catch(Exception ex)
|
248
|
+
{
|
249
|
+
Console.WriteLine("Updated row:");
|
250
|
+
DisplayRow(row);
|
251
|
+
throw new ApplicationException("Update in <%= table.Name %> failed",ex);
|
252
|
+
}
|
253
|
+
|
254
|
+
return row;
|
255
|
+
}
|
256
|
+
<%}// if (table.PrimaryKey.MemberColumns.Count != table.Columns.COunt) {%>
|
257
|
+
|
258
|
+
/// <summary>
|
259
|
+
/// Deletes a random row
|
260
|
+
/// from the <em><%= table.Name %></em> table.
|
261
|
+
/// </summary>
|
262
|
+
public virtual void Delete<%= Format(table.Name) %>()
|
263
|
+
{
|
264
|
+
// choose a row
|
265
|
+
DataRow row = this.<%=GetTablePopulatorPropertyName(table)%>.GetRandomRow();
|
266
|
+
|
267
|
+
// delete
|
268
|
+
this.Delete<%= Format(table.Name) %>(row);
|
269
|
+
}
|
270
|
+
|
271
|
+
/// <summary>
|
272
|
+
/// Deletes the row
|
273
|
+
/// from the <em><%= table.Name %></em> table.
|
274
|
+
/// </summary>
|
275
|
+
public virtual void Delete<%= Format(table.Name) %>(DataRow row)
|
276
|
+
{
|
277
|
+
if (row==null)
|
278
|
+
throw new ArgumentNullException("row");
|
279
|
+
|
280
|
+
// Delete the row from the <%= table.Name %> table
|
281
|
+
try
|
282
|
+
{
|
283
|
+
this.dal.<%= TableCollection(table) %>.DeleteByPrimaryKey(
|
284
|
+
<% for(int i = 0;i<table.PrimaryKey.MemberColumns.Count;++i){
|
285
|
+
ColumnSchema column =table.PrimaryKey.MemberColumns[i];%>
|
286
|
+
<%= (i!=0) ? "," : "" %>(<%= column.SystemType %>)row["<%= column.Name %>"]
|
287
|
+
<% } // foreach(ColumnSchema column in table.Columns) %>
|
288
|
+
);
|
289
|
+
}
|
290
|
+
catch(Exception ex)
|
291
|
+
{
|
292
|
+
Console.WriteLine("Deleted row:");
|
293
|
+
DisplayRow(row);
|
294
|
+
throw new ApplicationException("Delete in <%= table.Name %> failed",ex);
|
295
|
+
}
|
296
|
+
|
297
|
+
|
298
|
+
// check it is not in the table
|
299
|
+
DataRow readRow = Read<%= Format(table.Name) %>(row);
|
300
|
+
if (readRow!=null)
|
301
|
+
{
|
302
|
+
Console.WriteLine("Row to delete");
|
303
|
+
DisplayRow(row);
|
304
|
+
Console.WriteLine("Not deleted row");
|
305
|
+
DisplayRow(readRow);
|
306
|
+
Assert.Fail("Row delete failed");
|
307
|
+
}
|
308
|
+
}
|
309
|
+
|
310
|
+
/// <summary>
|
311
|
+
/// Reads the <em><%= table.Name %></em> table for a row matching <paramref name="row"/>
|
312
|
+
/// and returns it.
|
313
|
+
/// </summary>
|
314
|
+
/// <returns>
|
315
|
+
/// Read <see cref="DataRow"/> row if foud; otherwize
|
316
|
+
/// a null reference.
|
317
|
+
/// </returns>
|
318
|
+
public virtual DataRow Read<%= Format(table.Name) %>(DataRow row)
|
319
|
+
{
|
320
|
+
if (row==null)
|
321
|
+
throw new ArgumentNullException("row");
|
322
|
+
|
323
|
+
<%= TableRow(table) %> readRow = null;
|
324
|
+
try
|
325
|
+
{
|
326
|
+
readRow = this.dal.<%= TableCollection(table) %>.GetByPrimaryKey(
|
327
|
+
<% for(int i = 0;i<table.PrimaryKey.MemberColumns.Count;++i){
|
328
|
+
ColumnSchema column =table.PrimaryKey.MemberColumns[i];%>
|
329
|
+
<%= (i!=0) ? "," : "" %>(<%= column.SystemType %>)row["<%= column.Name %>"]
|
330
|
+
<% } // foreach(ColumnSchema column in table.Columns) %>
|
331
|
+
);
|
332
|
+
}
|
333
|
+
catch(Exception ex)
|
334
|
+
{
|
335
|
+
Console.WriteLine("Read row:");
|
336
|
+
DisplayRow(row);
|
337
|
+
throw new ApplicationException("Read in <%= table.Name %> failed",ex);
|
338
|
+
}
|
339
|
+
|
340
|
+
if (readRow==null)
|
341
|
+
return null;
|
342
|
+
|
343
|
+
DataRow rrow = row.Table.NewRow();
|
344
|
+
<% foreach(ColumnSchema column in table.Columns) {%>
|
345
|
+
<% if (column.SystemType.IsValueType && column.AllowDBNull) {%>
|
346
|
+
if (readRow.Is<%= Format(column.Name) %>Null)
|
347
|
+
rrow["<%=column.Name %>"] = DBNull.Value;
|
348
|
+
else
|
349
|
+
rrow["<%=column.Name %>"] = readRow.<%= Format(column.Name) %>;
|
350
|
+
<%} else { %>
|
351
|
+
rrow["<%=column.Name %>"] = readRow.<%= Format(column.Name) %>;
|
352
|
+
<%}%>
|
353
|
+
<% } // foreach(ColumnSchema column in table.Columns) %>
|
354
|
+
|
355
|
+
return rrow;
|
356
|
+
}
|
357
|
+
#endregion
|
358
|
+
|
359
|
+
<%} // foreach(TableSchema table in this.Database.Tables) %>
|
360
|
+
|
361
|
+
#region Misc
|
362
|
+
protected virtual void DisplayRow(DataRow row)
|
363
|
+
{
|
364
|
+
if (row==null)
|
365
|
+
throw new ArgumentNullException("row");
|
366
|
+
foreach(DataColumn column in row.Table.Columns)
|
367
|
+
{
|
368
|
+
Console.WriteLine("\t{0}: {1}",
|
369
|
+
column.ColumnName,
|
370
|
+
row[column].ToString());
|
371
|
+
}
|
372
|
+
}
|
373
|
+
#endregion
|
374
|
+
}
|
375
|
+
}
|
376
|
+
<script runat="template">
|
377
|
+
#region Properties
|
378
|
+
public string DatabaseName
|
379
|
+
{
|
380
|
+
get
|
381
|
+
{
|
382
|
+
return this.Database.Name;
|
383
|
+
}
|
384
|
+
}
|
385
|
+
public string TableRow(TableSchema table)
|
386
|
+
{
|
387
|
+
return Format("{0}Row",table.Name);
|
388
|
+
}
|
389
|
+
public string TableCollection(TableSchema table)
|
390
|
+
{
|
391
|
+
return Format("{0}Collection",table.Name);
|
392
|
+
}
|
393
|
+
public string DataSetName
|
394
|
+
{
|
395
|
+
get{ return Format(this.DataSetNameFormat, this.DatabaseName);}
|
396
|
+
}
|
397
|
+
public string CrudPopulatorName
|
398
|
+
{
|
399
|
+
get{ return Format(this.CrudPopulatorNameFormat,this.DatabaseName);}
|
400
|
+
}
|
401
|
+
public string DatabasePopulatorName
|
402
|
+
{
|
403
|
+
get{ return Format(this.DatabasePopulatorNameFormat,this.DatabaseName);}
|
404
|
+
}
|
405
|
+
public string GetTablePopulatorName(TableSchema table)
|
406
|
+
{
|
407
|
+
return Format(this.TablePopulatorNameFormat, table.Name);
|
408
|
+
}
|
409
|
+
public string GetTablePopulatorPropertyName(TableSchema table)
|
410
|
+
{
|
411
|
+
return Format(table.Name);
|
412
|
+
}
|
413
|
+
public string GetColumnDataGeneratorName(ColumnSchema column)
|
414
|
+
{
|
415
|
+
return Format(ColumnDataGeneratorNameFormat, column.Name);
|
416
|
+
}
|
417
|
+
public string GetUniqueValidatorName(TableKeySchema unique)
|
418
|
+
{
|
419
|
+
return Format(UniqueValidatorNameFormat, unique.Name);
|
420
|
+
}
|
421
|
+
public string GetForeignKeyProviderName(TableKeySchema unique)
|
422
|
+
{
|
423
|
+
return Format(ForeignKeyProviderNameFormat, unique.Name);
|
424
|
+
}
|
425
|
+
protected string FormatLower(string format, params object[] args)
|
426
|
+
{
|
427
|
+
string s= Format(format,args);
|
428
|
+
return Char.ToLower(s[0]) + s.Substring(1);
|
429
|
+
}
|
430
|
+
protected string Format(string format, params Object[] args)
|
431
|
+
{
|
432
|
+
string result = string.Format(format,args);
|
433
|
+
if (this.TableNamePrefix!=null && this.TableNamePrefix.Length > 0)
|
434
|
+
{
|
435
|
+
if (result.StartsWith(this.TableNamePrefix))
|
436
|
+
result = result.Substring(this.TableNamePrefix.Length);
|
437
|
+
}
|
438
|
+
|
439
|
+
result = result.Replace(" ","").Replace("_","").Replace(".","");
|
440
|
+
return result;
|
441
|
+
}
|
442
|
+
|
443
|
+
#endregion
|
444
|
+
</script>
|
@@ -0,0 +1,91 @@
|
|
1
|
+
<%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="A simple TestFixture generator" %>
|
2
|
+
<%@ Property Name="Class" Type="System.String" Category="Appearance" Description="Tested class name." %>
|
3
|
+
<%@ Property Name="Namespace" Type="System.String" Category="Appearance" Description="Tested class namespace." %>
|
4
|
+
<%@ Property Name="TestNamespace" Type="System.String" Category="Appearance" Description="Test namespace." %>
|
5
|
+
<%@ Property Name="Fixture" Type="FixtureType" Category="Options" Appearance="Fixture has setup" %>
|
6
|
+
<%@ Property Name="SetUp" Type="System.Boolean" Category="Options" Default="false" Description="Fixture has setup" %>
|
7
|
+
<%@ Property Name="TearDown" Type="System.Boolean" Category="Options" Default="false" Description="Fixture has setup" %>
|
8
|
+
<%@ Property Name="TestClassFormat" Type="System.String" Category="Options" Default="{0}Test" Description="Format string for creating TestClass" %>
|
9
|
+
|
10
|
+
#region Includes
|
11
|
+
using System;
|
12
|
+
using System.Collections;
|
13
|
+
using System.IO;
|
14
|
+
using MbUnit.Core.Framework;
|
15
|
+
using MbUnit.Framework;
|
16
|
+
#endregion
|
17
|
+
|
18
|
+
using <%= Namespace %>;
|
19
|
+
|
20
|
+
namespace <%= TestNamespace %>
|
21
|
+
{
|
22
|
+
/// <summary>
|
23
|
+
/// <see cref="<%= Fixture %>"/> for the <see cref="<%= Class %>"/> class.
|
24
|
+
/// </summary>
|
25
|
+
[<%= FixtureAttribute %>]
|
26
|
+
public class <%= TestClass %>
|
27
|
+
{
|
28
|
+
<% if (this.SetUpOrTearDown) {%>
|
29
|
+
#region SetUp and TearDown
|
30
|
+
<% if (this.SetUp) {%>
|
31
|
+
[SetUp]
|
32
|
+
public void SetUp()
|
33
|
+
{
|
34
|
+
throw new NotImplemented();
|
35
|
+
}
|
36
|
+
<%}%>
|
37
|
+
<% if (this.TearDown) {%>
|
38
|
+
[TearDown]
|
39
|
+
public void TearDown()
|
40
|
+
{
|
41
|
+
throw new NotImplemented();
|
42
|
+
}
|
43
|
+
<%}%>
|
44
|
+
#endregion
|
45
|
+
<%}%>
|
46
|
+
|
47
|
+
#region Tests
|
48
|
+
#endregion
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
<script runat="template">
|
53
|
+
public enum FixtureType
|
54
|
+
{
|
55
|
+
TestFixture,
|
56
|
+
TypeFixture,
|
57
|
+
DataFixture,
|
58
|
+
ProcessTestFixture,
|
59
|
+
TestSuiteFixture,
|
60
|
+
CollectionIndexingFixture,
|
61
|
+
CollectionOrderFixture,
|
62
|
+
EnumerationFixture
|
63
|
+
}
|
64
|
+
|
65
|
+
public bool SetUpOrTearDown
|
66
|
+
{
|
67
|
+
get
|
68
|
+
{
|
69
|
+
return this.SetUp || this.TearDown;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
public string FixtureAttribute
|
74
|
+
{
|
75
|
+
get
|
76
|
+
{
|
77
|
+
if(this.Fixture == FixtureType.TypeFixture)
|
78
|
+
return "TypeFixture(typeof(PutTestedTypeHere))";
|
79
|
+
|
80
|
+
return this.Fixture.ToString();
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
public string TestClass
|
85
|
+
{
|
86
|
+
get
|
87
|
+
{
|
88
|
+
return String.Format(this.TestClassFormat, this.Class);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
</script>
|