[5a4bff]: / Interfaces / +APUnitTestFramework / MockConstructor.cs  Maximize  Restore  History

Download this file

39 lines (34 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
namespace _3S.APUnitTestFramework
{
///// <summary>
///// This delegate is used in the call to <see cref="Testbed.AddMock(System.Guid,
///// MockConstructor)"/>. Implementations must return a mock instance of the appropriate type.
///// </summary>
///// <returns>
///// A mock instance of the appropriate type. Implementations must not return <c>null</c>.
///// </returns>
///// <remarks>
///// Mock constructors are sometimes called by the framework just to reflect the returned type,
///// so without injecting the result into a dependency. This is indicated by the <paramref name=
///// "reflectionOnly"/> parameter. Implementations might use this parameter in order to not
///// attach to some events prematurely.
///// </remarks>
//public delegate object MockConstructor(bool reflectionOnly);
public class MockConstructor
{
public Func<object> CreateFunc { get; private set; }
public Func<object> CreatePrototypeFunc { get; private set; }
public bool SystemInstance { get; private set; }
internal MockConstructor(Func<object> createFunc, Func<object> createPrototypeFunc, bool systemInstance)
{
if (createFunc == null)
throw new ArgumentNullException(nameof(createFunc));
if (createPrototypeFunc == null)
throw new ArgumentNullException(nameof(createPrototypeFunc));
CreateFunc = createFunc;
CreatePrototypeFunc = createPrototypeFunc;
SystemInstance = systemInstance;
}
}
}