%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="Assert Tester Wrapper" Debug="True"%>
<%@ Property Name="Class" Type="System.String" Category="Options" Description="Prefix of the class name, Assert will be appended." %>
<%@ Property Name="Namespace" Type="System.String" Category="Options" Description="Namespace of the wrapped class" %>
<%@ Property Name="TestNamespace" Type="System.String" Category="Options" Description="Namespace of the generated test" Optional="False" %>
<%@ Property Name="AsTypeFixture" Type="System.Boolean" Category="Options" Description="Generate as Type fixture" %>
<%@ Property Name="TestConstructors" Type="System.Boolean" Category="Options" Description="Generate tests for constructors" Default="True" %>
<%@ Property Name="TestAllProperties" Type="System.Boolean" Category="Options" Description="Generate tests for constructors" Default="True" %>
<%@ Property Name="TestAllMethods" Type="System.Boolean" Category="Options" Description="Generate tests for constructors" Default="True" %>
<%@ Property Name="TestMethodsDeep" Type="System.Boolean" Category="Options" Description="Generate tests for constructors" Default="True" %>
<%@ Assembly Name="AssemblyHelper"%>
<%@ Assembly Name="ILReader"%>
<%@ Assembly Name="QuickGraph.Applications"%>
<%@ Assembly Name="QuickGraph"%>
<%@ Assembly Name="QuickGraph.Concepts"%>
<%@ Assembly Name="QuickGraph.Collections"%>
<%@ Import Namespace="System.Reflection" %>
<%@ Import Namespace="System.Reflection.Emit" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Text.RegularExpressions" %>
<%@ Import Namespace="AssemblyHelper" %>
<%@ Import Namespace="Reflector.Disassembler"%>
using System;
using MbUnit.Core.Framework;
using MbUnit.Framework;
using <%= Namespace %>;
namespace <%= TestNamespace %>
{
///
/// Unit test fixture for the <%=SeeClass %>
///
///
///
/// This class was originially generated by a template.
/// When created, it contains Ignored empty test only. This is just a tool, don't expect intelligent
/// testing here.
///
///
<% if (AsTypeFixture){%>
[TypeFixture(typeof(<%= Class %>))]
<%}else{%>
[TestFixture]
<%}%>
public class <%= Fixture %>
{
<% if (!AsTypeFixture) { %>
#region private members
private <%= Class %> instance = null;
#endregion
#region Set up and tear down
///
/// Sets the instance.
///
///
///
/// Allocates an <%= SeeClass %> instance to be used in the tests.
///
///
/// Not implemented.
///
///
[SetUp]
public void SetUp()
{
throw new NotImplementedException();
}
///
/// Releases the resources allocated for the fixture.
///
///
///
/// Make this method release resource allocated for/during the test.
///
<%if (ClassType is IDisposable){%>
///
/// Disposes the instance method.
///
<%}%>
///
/// Not implemented.
///
///
[TearDown]
public void TearDown()
{
<%if (ClassType is IDisposable){%>
if (this.instance!=null)
{
this.instance.Dispose();
this.instance=null;
}
<%}%>
throw new NotImplementedException();
}
#endregion
<% if (TestConstructors) {%>
#region Constructors
<% foreach(ConstructorInfo ci in this.ClassType.GetConstructors()){%>
///
/// Tests the constructor that takes following arguments:
/// <%= ParameterToComment(ci.GetParameters()) %>
///
[Test]
[Ignore("Needs implementation")]
public void <%= ConstructorSignature(ci) %>()
{
throw new NotImplementedException();
}
<%}%>
#endregion
<%}%>
<%}%>
#region Testing properties
<% if (this.TestAllProperties){
foreach(PropertyInfo pi in this.ClassType.GetProperties())
{
if (pi.CanRead)
{%>
///
/// Verifies that the property can be get.
///
///
///
/// Tries to retreives the value of the property.
///
///
/// Not implemented.
///
///
<% AddArgsComment(); %>
[Test("Tests the <%= pi.Name %> can be read")]
[Ignore("Needs implementation")]
public void Get<%= pi.Name %>Test(<%= Args %>)
{
<%= pi.PropertyType %> value = <%= Instance%>.<%= pi.Name %>;
throw new NotImplementedException();
}
<%}
if (pi.CanWrite)
{%>
///
/// Verifies that the property can be set.
///
///
///
/// Not implemented.
///
///
<% AddArgsComment(); %>
[Test("Tests the <%= pi.Name %> can be written")]
[Ignore("Needs implementation")]
public void Set<%= pi.Name %>Test(<%= Args %>)
{
<%= pi.PropertyType %> value;
<%= Instance %>.<%= pi.Name %> = value;
throw new NotImplementedException();
}
<%}%>
<%}}%>
#endregion
#region Method tests
<% if(this.TestAllMethods){
foreach(MethodInfo mi in this.ClassType.GetMethods())
{
if (mi.Name.StartsWith("get_") || mi.Name.StartsWith("set_"))
continue;%>
///
/// Tests the method
///
///
///
/// Not implemented
///
///
<% AddArgsComment(); %>
[Test]
[Ignore("Needs implementation")]
public void <%= Beautify(mi.Name) %>(<%= Args%>)
{
throw new NotImplementedException();
}
<%}}%>
<%if (this.TestMethodsDeep){
ModuleReader reader = new ModuleReader(this.ClassType.Module, new AssemblyProvider());
foreach (MethodInfo mi in this.ClassType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly))
{
MethodBody methodBody = reader.GetMethodBody(mi);
int index = -1;
foreach(ICollection path in IlGrapher.IlGraphBuilder.GetAllEdgesPath(mi))
{
index++;
%>
///
/// Tests that the method throws (see remarks)
///
///
///
/// Not implemented
///
<% RenderPathToCode(methodBody, path); %>
///
<% AddArgsComment(); %>
[Test]
[Ignore("Needs implementation")]
public void <%= Beautify(mi.Name) %><%= index %>(<%= Args%>)
{
// don't forget to update the exception type.
throw new NotImplementedException();
}
<% }
}
}%>
#endregion
}
}