protected void StubNativeMethodsForWindowInformation(
     IWin32WindowsNativeMethods nativeMethodsStub, IntPtr windowHandle, int processID, string className, string windowText)
 {
     StubGetWindowThreadProcessID(nativeMethodsStub, windowHandle, processID);
     StubGetClassName(nativeMethodsStub, windowHandle, className);
     StubGetWindowText(nativeMethodsStub, windowHandle, windowText);
 }
        public virtual void SetUp()
        {
            var currentProcess = Process.GetCurrentProcess();

            _currentProcessID  = currentProcess.Id;
            _nativeMethodsStub = MockRepository.GenerateStub <IWin32WindowsNativeMethods>();

            _windowFinder = new NativeWindowFinder(_nativeMethodsStub);
        }
Beispiel #3
0
 public WindowFinderEnumChildWindowsProcContext(
     IWin32WindowsNativeMethods nativeMethods,
     Regex classNameConstraint,
     Regex windowTextConstraint,
     WindowInformation parentWindow)
     : base(nativeMethods, classNameConstraint, windowTextConstraint)
 {
     _parentWindow = parentWindow;
 }
        public NativeWindowFinder(IWin32WindowsNativeMethods nativeMethods)
        {
            ArgumentUtility.CheckNotNull("nativeMethods", nativeMethods);

            _nativeMethods = nativeMethods;
            var currentProcess = Process.GetCurrentProcess();

            _currentProcessID = currentProcess.Id;
        }
        protected WindowFinderEnumWindowsProcContextBase(
            IWin32WindowsNativeMethods nativeMethods,
            Regex classNameConstraint,
            Regex windowTextConstraint)
        {
            ArgumentUtility.CheckNotNull("nativeMethods", nativeMethods);

            _nativeMethods        = nativeMethods;
            _classNameConstraint  = classNameConstraint;
            _windowTextConstraint = windowTextConstraint;
        }
 public WindowFinderEnumWindowsProcContext(
     IWin32WindowsNativeMethods nativeMethods,
     int?ownProcessIDConstraint,
     int?processIDConstraint,
     Regex classNameConstraint,
     Regex windowTextConstraint,
     bool includeChildWindows)
     : base(nativeMethods, classNameConstraint, windowTextConstraint)
 {
     _ownProcessIDConstraint = ownProcessIDConstraint;
     _processIDConstraint    = processIDConstraint;
     _includeChildWindows    = includeChildWindows;
 }
 private void StubGetWindowText(IWin32WindowsNativeMethods nativeMethodsStub, IntPtr windowHandle, string windowText)
 {
     nativeMethodsStub.Stub(stub => stub.GetWindowText(Arg.Is(windowHandle), Arg <StringBuilder> .Is.NotNull, Arg.Is(1024)))
     .WhenCalled(mi => ((StringBuilder)mi.Arguments[1]).Append(windowText))
     .Return(windowText.Length);
 }
 private void StubGetClassName(IWin32WindowsNativeMethods nativeMethodsStub, IntPtr windowHandle, string className)
 {
     nativeMethodsStub.Stub(stub => stub.GetClassName(Arg.Is(windowHandle), Arg <StringBuilder> .Is.NotNull, Arg.Is(256)))
     .WhenCalled(mi => ((StringBuilder)mi.Arguments[1]).Append(className))
     .Return(className.Length);
 }
 private void StubGetWindowThreadProcessID(IWin32WindowsNativeMethods nativeMethodsStub, IntPtr windowHandle, int processID)
 {
     nativeMethodsStub.Stub(stub => stub.GetWindowThreadProcessID(windowHandle)).Return(processID);
 }