--- a +++ b/Interfaces/+APUnitTestFramework/MockConstructor.cs @@ -0,0 +1,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; + } + } +}