Diff of /Interfaces/+APUnitTestFramework/MockConstructor.cs [000000] .. [5a4bff]  Maximize  Restore

Switch to unified view

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