<%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="Basic Mock Object template." %> <%@ Property Name="Interface" Type="System.String" Category="Options" Description="Interface to mock" %> <%@ Property Name="Namespace" Type="System.String" Category="Options" Description="Namespace of the wrapped class" %> <%@ Property Name="MockNamespace" Type="System.String" Category="Options" Description="Namespace of the wrapped class" %> <%@ Import Namespace="System.Reflection" %> <%@ Import Namespace="System.Collections" %> <%@ Import Namespace="System.Collections.Specialized" %> <%@ Import Namespace="System.IO" %> <%@ Import Namespace="System.ComponentModel.Design" %> <%@ Import Namespace="System.Drawing.Design" %> <%@ Assembly Name="AssemblyHelper"%> <%@ Assembly Name="System.Design"%> <%@ Import Namespace="AssemblyHelper" %> using System; using DotNetMock; using <%= Namespace %> namespace <%= MockNamespace %> { /// /// Mock of the <%= SeeInterface %> interface. /// /// /// This class was generated and needs some work :) /// public class <%= MockClass %> : <%= Interface %>, MockObject { #region Private fields <% foreach(ExpectationEntry ep in this.expectations){%> private <%= ep.ExpectedType %> <%= ep.FieldName %> = new <%= ep.ExpectedType %>("<%= MockClass %>.<%= ep.Name %>"); <%}%> #endregion #region MockObject /// /// Default Constructor /// public <%= MockClass %>() {} /// /// Constructor. Sets the name of this /// /// Name of this MockObject public <%= MockClass %>(string name) :base(name) {} <% foreach(ExpectationEntry ep in this.expectations){%> /// /// Sets the ... affected /// /// /// Expected value. /// public void <%= ep.MethodName() %>(<%= ep.ValueType %> expected) { this.<%= ep.Name %>.Expected = expected; this.NotImplemented("Set<%= ep.MethodName() %>"); } <%}%> #endregion #region <%= Interface %> members <% foreach(MethodInfo mi in this.InterfaceType.GetMethods()){ if (mi.Name.StartsWith("get_") || mi.Name.StartsWith("set_")) continue; %> <%= mi.ReturnType %> <%= this.InterfaceType.Name %>.<%= mi.Name %>(<%= MethodParameters(mi) %>) { this.NotImplemented("<%= mi.Name %>"); } <% }%> <% foreach(PropertyInfo pi in this.InterfaceType.GetProperties()){%> <%= pi.PropertyType %> <%= this.InterfaceType.Name %>.<%= pi.Name %><%= PropertyParameters(pi) %> { <% if (pi.CanRead){%> get { this.NotImplemented("get <%= pi.Name %>"); } <% } if (pi.CanWrite){%> get { this.NotImplemented("set <%= pi.Name %>"); } <% }%> } <% }%> #endregion <% foreach(Type it in this.InterfaceType.GetInterfaces()) {%> #region <%= it.Name %> members <% foreach(MethodInfo mi in it.GetMethods()){ if (mi.Name.StartsWith("get_") || mi.Name.StartsWith("set_")) continue; %> <%= mi.ReturnType %> <%= it.Name %>.<%= mi.Name %>(<%= MethodParameters(mi) %>) { this.NotImplemented("<%= mi.Name %>"); } <% }%> <% foreach(PropertyInfo pi in it.GetProperties()){%> <%= pi.PropertyType %> <%= it.Name %>.<%= pi.Name %><%= PropertyParameters(pi) %> { <% if (pi.CanRead){%> get { this.NotImplemented("get <%= pi.Name %>"); } <% } if (pi.CanWrite){%> get { this.NotImplemented("set <%= pi.Name %>"); } <% }%> } <% }%> #endregion <%}%> } }