2009-06-12 Bill Holmes <billholmes54@gmail.com>
[mono.git] / mcs / nunit20 / mocks / DynamicMock.cs
1 using System;
2
3 namespace NUnit.Mocks
4 {
5         /// <summary>
6         /// Summary description for DynamicMock.
7         /// </summary>
8         public class DynamicMock : Mock
9         {
10                 private Type type;
11
12                 private object mockInstance;
13
14                 public object MockInstance
15                 {
16                         get 
17                         { 
18                                 if ( mockInstance == null )
19                                 {
20                                         MockInterfaceHandler handler = new MockInterfaceHandler( type, this );
21                                         mockInstance = handler.GetTransparentProxy();
22                                 }
23
24                                 return mockInstance; 
25                         }
26                 }
27
28                 #region Constructors
29
30                 public DynamicMock( Type type ) : this( "Mock" + type.Name, type ) { }
31
32                 public DynamicMock( string name, Type type ) : base( name )
33                 {
34 //                      if ( !type.IsInterface )
35 //                              throw new VerifyException( "DynamicMock constructor requires an interface type" );
36                         this.type = type;
37                 }
38
39                 #endregion
40         }
41 }