/// <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)); }
/// <inheritdoc/> public Fake Mock(Type parent, params Type[] interfaces) { IFaked provider = Subclasser.Create(parent, interfaces); provider.FakeMeta.Valuer = _valuer; return(new Fake(provider)); }
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(); }
/// <inheritdoc/> public bool Supports(Type type) { return(Subclasser.Supports(type)); }
/// <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))); }
internal static void CreateInfo_NoDuplicatesCreated() { Tools.Asserter.Is(Subclasser.CreateInfo(typeof(IFakeSample), typeof(IClashingFakeSample)), Subclasser.CreateInfo(typeof(IClashingFakeSample), typeof(IFakeSample))); }
internal static void Create_SealedTypesThrow() { Tools.Asserter.Throws <ArgumentException>(() => Subclasser.Create <string>()); }
internal static void Create_OnlyMultipleInterfaces() { Tools.Asserter.Throws <ArgumentException>(() => Subclasser.Create <DataSample>(typeof(object))); }
internal static void Create_IFakedFunctional() { Tools.Asserter.IsNot(null, Subclasser.Create <IFaked>().FakeMeta); }
internal static void Create_IFakedDefault() { Tools.Asserter.Is(true, Subclasser.Create <object>() is IFaked); Tools.Asserter.IsNot(null, Subclasser.Create(null, null)); }
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))); }
internal static void Create_ClassesWork() { Tools.Asserter.IsNot(null, Subclasser.Create <AbstractFakeSample>()); Tools.Asserter.IsNot(null, Subclasser.Create <VirtualFakeSample>()); }
internal static void CreateInfo_IgnoreDupeInterfaces() { Tools.Asserter.Is(Subclasser.CreateInfo(typeof(IFakeSample)), Subclasser.CreateInfo(typeof(IFakeSample), typeof(IFakeSample))); }
internal static void Create_InternalTypesThrow() { Tools.Asserter.Throws <ArgumentException>(() => Subclasser.Create <InternalSample>()); }