示例#1
0
        /// <inheritdoc/>
        public Fake <T> Mock <T>(params Type[] interfaces)
        {
            IFaked provider = Subclasser.Create(typeof(T), interfaces);

            provider.FakeMeta.Valuer = _valuer;
            return(new Fake <T>(provider));
        }
示例#2
0
        /// <inheritdoc/>
        public Fake Mock(Type parent, params Type[] interfaces)
        {
            IFaked provider = Subclasser.Create(parent, interfaces);

            provider.FakeMeta.Valuer = _valuer;
            return(new Fake(provider));
        }
示例#3
0
        protected override void ApplyHook(string args)
        {
            MessageHook hook     = null;
            Subclasser  subclass = null;

            /* We will have been injected into the remote process using CreateRemoteThread meaning we will
             * not be on the UI thread. Therefore we need to subclass the main window of the process and
             * then trigger our message hook after the first message has been received as we will be on
             * the UI thread.
             */
            subclass = new Subclasser(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle, delegate(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam)
            {
                //Unsubclass the window as we are performing a hook
                subclass.Restore();
                if (hook == null)
                {
                    hook = new MessageHook(new LocalHook());
                    hook.SetHook();
                    hook.MessageReceived += MessageReceived;
                }
                return(false);
            });
            subclass.Hook();
        }
示例#4
0
 /// <inheritdoc/>
 public bool Supports(Type type)
 {
     return(Subclasser.Supports(type));
 }
示例#5
0
 /// <inheritdoc/>
 public bool Supports <T>()
 {
     return(Subclasser.Supports <T>());
 }
 internal static void Create_PointersThrow()
 {
     Tools.Asserter.Throws <ArgumentException>(() => Subclasser.Create(typeof(void *)));
 }
 internal static void Create_UndefinedGenericsThrow()
 {
     Tools.Asserter.Throws <ArgumentException>(() => Subclasser.Create(typeof(ConstraintSample <,>)));
 }
 internal static void Create_DefinedGenericsWork()
 {
     Tools.Asserter.IsNot(null, Subclasser.Create <ConstraintSample <int, DataSample> >());
     Tools.Asserter.IsNot(null, Subclasser.Create <ConstraintSample <bool, DataSample> >());
 }
 internal static void Create_InterfacesWork()
 {
     Tools.Asserter.IsNot(null, Subclasser.Create <IFakeSample>());
     Tools.Asserter.IsNot(null, Subclasser.Create <IFakeSample>(typeof(IClashingFakeSample)));
 }
示例#10
0
 internal static void CreateInfo_NoDuplicatesCreated()
 {
     Tools.Asserter.Is(Subclasser.CreateInfo(typeof(IFakeSample), typeof(IClashingFakeSample)),
                       Subclasser.CreateInfo(typeof(IClashingFakeSample), typeof(IFakeSample)));
 }
示例#11
0
 internal static void Create_SealedTypesThrow()
 {
     Tools.Asserter.Throws <ArgumentException>(() => Subclasser.Create <string>());
 }
示例#12
0
 internal static void Create_OnlyMultipleInterfaces()
 {
     Tools.Asserter.Throws <ArgumentException>(() => Subclasser.Create <DataSample>(typeof(object)));
 }
示例#13
0
 internal static void Create_IFakedFunctional()
 {
     Tools.Asserter.IsNot(null, Subclasser.Create <IFaked>().FakeMeta);
 }
示例#14
0
 internal static void Create_IFakedDefault()
 {
     Tools.Asserter.Is(true, Subclasser.Create <object>() is IFaked);
     Tools.Asserter.IsNot(null, Subclasser.Create(null, null));
 }
示例#15
0
 internal static void Create_BothWork()
 {
     Tools.Asserter.IsNot(null, Subclasser.Create <AbstractFakeSample>(typeof(IFakeSample)));
     Tools.Asserter.IsNot(null, Subclasser.Create <VirtualFakeSample>(
                              typeof(IFakeSample), typeof(IClashingFakeSample)));
 }
示例#16
0
 internal static void Create_ClassesWork()
 {
     Tools.Asserter.IsNot(null, Subclasser.Create <AbstractFakeSample>());
     Tools.Asserter.IsNot(null, Subclasser.Create <VirtualFakeSample>());
 }
示例#17
0
 internal static void CreateInfo_IgnoreDupeInterfaces()
 {
     Tools.Asserter.Is(Subclasser.CreateInfo(typeof(IFakeSample)),
                       Subclasser.CreateInfo(typeof(IFakeSample), typeof(IFakeSample)));
 }
示例#18
0
 internal static void Create_InternalTypesThrow()
 {
     Tools.Asserter.Throws <ArgumentException>(() => Subclasser.Create <InternalSample>());
 }