Esempio n. 1
0
        public int RasDial(ref RASDIALEXTENSIONS lpRasDialExtensions, string lpszPhoneBook, ref RASDIALPARAMS lpRasDialParams, NotifierType dwNotifierType, RasDialFunc2 lpvNotifier, out IntPtr lphRasConn)
        {
            var stopwatch = Stopwatch.StartNew();
            var result    = AttachedObject.RasDial(ref lpRasDialExtensions, lpszPhoneBook, ref lpRasDialParams, dwNotifierType, lpvNotifier, out lphRasConn);

            stopwatch.Stop();

            var callEvent = new PInvokeInt32CallCompletedTraceEvent
            {
                DllName    = RasApi32Dll,
                Duration   = stopwatch.Elapsed,
                MethodName = nameof(RasDial),
                Result     = result,
            };

            callEvent.Args.Add(nameof(lpRasDialExtensions), lpRasDialExtensions);
            callEvent.Args.Add(nameof(lpszPhoneBook), lpszPhoneBook);
            callEvent.Args.Add(nameof(lpRasDialParams), lpRasDialParams);
            callEvent.Args.Add(nameof(dwNotifierType), dwNotifierType);
            callEvent.Args.Add(nameof(lpvNotifier), lpvNotifier);
            callEvent.OutArgs.Add(nameof(lphRasConn), lphRasConn);

            LogVerbose(callEvent);
            return(result);
        }
Esempio n. 2
0
 public static extern int RasDial(
     [In] ref RASDIALEXTENSIONS lpRasDialExtensions,
     string lpszPhoneBook,
     [In] ref RASDIALPARAMS lpRasDialParams,
     NotifierType dwNotifierType,
     Delegate lpvNotifier,
     out IntPtr lphRasConn);
Esempio n. 3
0
 public static extern uint RasDial(
     [In] RASDIALEXTENSIONS lpRasDialExtensions,
     [In] string lpszPhonebook,
     [In] RASDIALPARAMS lpRasDialParams,
     uint dwNotifierType,
     Delegate lpvNotifier,
     ref IntPtr lphRasConn);
Esempio n. 4
0
        public void RasDialAsExpected()
        {
            var lpRasDialExtensions = new RASDIALEXTENSIONS();
            var lpszPhoneBook       = @"C:\Users\My.pbk";

            var          lpRasDialParams = new RASDIALPARAMS();
            var          dwNotifierType  = NotifierType.RasDialFunc2;
            RasDialFunc2 lpvNotifier     = null;
            var          lphRasConn      = IntPtr.Zero;

            api.Setup(o => o.RasDial(ref It.Ref <RASDIALEXTENSIONS> .IsAny, lpszPhoneBook, ref It.Ref <RASDIALPARAMS> .IsAny, dwNotifierType, lpvNotifier, out It.Ref <IntPtr> .IsAny)).Returns(new RasDialCallback(
                                                                                                                                                                                                    (ref RASDIALEXTENSIONS o1, string o2, ref RASDIALPARAMS o3, NotifierType o4, RasDialFunc2 o5, out IntPtr o6) =>
            {
                o6 = new IntPtr(1);
                return(SUCCESS);
            }));

            eventLoggingPolicy.Setup(o => o.LogEvent(It.IsAny <EventLevel>(), It.IsAny <PInvokeInt32CallCompletedTraceEvent>())).Callback(new LogEventCallback(
                                                                                                                                              (level, o1) =>
            {
                Assert.AreEqual(EventLevel.Verbose, level);

                var eventData = (PInvokeInt32CallCompletedTraceEvent)o1;
                Assert.True(eventData.Args.ContainsKey(nameof(lpRasDialExtensions)));
                Assert.True(eventData.Args.ContainsKey(nameof(lpszPhoneBook)));
                Assert.True(eventData.Args.ContainsKey(nameof(lpRasDialParams)));
                Assert.True(eventData.Args.ContainsKey(nameof(dwNotifierType)));
                Assert.True(eventData.Args.ContainsKey(nameof(lpvNotifier)));
                Assert.True(eventData.OutArgs.ContainsKey(nameof(lphRasConn)));

                Assert.True(eventData.Duration > TimeSpan.Zero);
                Assert.AreEqual(SUCCESS, eventData.Result);
            })).Verifiable();

            var target = new RasApi32LoggingAdvice(api.Object, eventLoggingPolicy.Object);
            var result = target.RasDial(ref lpRasDialExtensions, lpszPhoneBook, ref lpRasDialParams, dwNotifierType, null, out lphRasConn);

            eventLoggingPolicy.Verify();
            Assert.AreEqual(SUCCESS, result);
            Assert.AreEqual(new IntPtr(1), lphRasConn);
        }
Esempio n. 5
0
 public int RasDial(ref RASDIALEXTENSIONS lpRasDialExtensions, string lpszPhoneBook, ref RASDIALPARAMS lpRasDialParams, NotifierType dwNotifierType, RasDialFunc2 lpvNotifier, out IntPtr lphRasConn)
 {
     return(UnsafeNativeMethods.RasDial(ref lpRasDialExtensions, lpszPhoneBook, ref lpRasDialParams, dwNotifierType, lpvNotifier, out lphRasConn));
 }