public void GetProjectionInfoIkeV2Test() { RasIkeV2Info expected = new RasIkeV2Info(0, IPAddress.Any, IPAddress.Any, 0, IPAddress.Any, IPAddress.Any, 0, RasIkeV2AuthenticationType.None, 0, new RasIkeV2Options(), RasIPSecEncryptionType.None, null, null); Mock<IRasHelper> mock = new Mock<IRasHelper>(); RasHelper.Instance = mock.Object; mock.Setup(o => o.GetProjectionInfoEx(It.IsAny<RasHandle>())).Returns(expected); RasConnection target = new RasConnection(); RasIkeV2Info actual = (RasIkeV2Info)target.GetProjectionInfo(RasProjectionType.IkeV2); Assert.AreSame(expected, actual); }
public void GetIpAddress(out string ipAddress, out RasConnection oldConn) { ipAddress = ""; var conns = RasConnection.GetActiveConnections(); oldConn = conns.FirstOrDefault(conn => conn.Device.DeviceType.ToString().ToLower() == "pppoe"); if (oldConn != null) { try { RasIPInfo ipAddresses = (RasIPInfo) oldConn.GetProjectionInfo(RasProjectionType.IP); ipAddress = ipAddresses.IPAddress.ToString(); } catch (Exception ex) { LogServer.WriteLog(ex, "changeIp"); } } }
public void GetProjectionInfoPppTest() { RasPppInfo expected = new RasPppInfo(0, IPAddress.Any, IPAddress.Any, new RasIPOptions(NativeMethods.RASIPO.None), new RasIPOptions(NativeMethods.RASIPO.None), 0, null, null, false, false, RasLcpAuthenticationType.None, RasLcpAuthenticationDataType.None, RasLcpAuthenticationType.None, RasLcpAuthenticationDataType.None, 0, 0, new RasLcpOptions(), new RasLcpOptions(), RasCompressionType.None, RasCompressionType.None, new RasCompressionOptions(), new RasCompressionOptions()); Mock<IRasHelper> mock = new Mock<IRasHelper>(); RasHelper.Instance = mock.Object; mock.Setup(o => o.GetProjectionInfoEx(It.IsAny<RasHandle>())).Returns(expected); RasConnection target = new RasConnection(); RasPppInfo actual = (RasPppInfo)target.GetProjectionInfo(RasProjectionType.Ppp); Assert.AreSame(expected, actual); }
public void GetProjectionInfoNullApiResultTest() { RasPppInfo expected = null; Mock<IRasHelper> mock = new Mock<IRasHelper>(); RasHelper.Instance = mock.Object; mock.Setup(o => o.GetProjectionInfoEx(It.IsAny<RasHandle>())).Returns(expected); RasConnection target = new RasConnection(); RasPppInfo actual = (RasPppInfo)target.GetProjectionInfo(RasProjectionType.Ppp); Assert.AreEqual(expected, actual); }
public void GetProjectionInfoSlipTest() { RasSlipInfo expected = new RasSlipInfo(0, IPAddress.Any); Mock<IRasHelper> mock = new Mock<IRasHelper>(); RasHelper.Instance = mock.Object; mock.Setup(o => o.GetProjectionInfo(It.IsAny<RasHandle>(), NativeMethods.RASPROJECTION.Slip)).Returns(expected); RasConnection target = new RasConnection(); RasSlipInfo actual = (RasSlipInfo)target.GetProjectionInfo(RasProjectionType.Slip); Assert.AreSame(expected, actual); }
public void GetProjectionInfoLcpTest() { RasLcpInfo expected = new RasLcpInfo(false, 0, RasLcpAuthenticationType.None, RasLcpAuthenticationDataType.None, 0, RasLcpAuthenticationType.None, RasLcpAuthenticationDataType.None, 0, false, 0, 0, null, new RasLcpOptions(), new RasLcpOptions()); Mock<IRasHelper> mock = new Mock<IRasHelper>(); RasHelper.Instance = mock.Object; mock.Setup(o => o.GetProjectionInfo(It.IsAny<RasHandle>(), NativeMethods.RASPROJECTION.Lcp)).Returns(expected); RasConnection target = new RasConnection(); RasLcpInfo actual = (RasLcpInfo)target.GetProjectionInfo(RasProjectionType.Lcp); Assert.AreSame(expected, actual); }
public void GetProjectionInfoCcpTest() { RasCcpInfo expected = new RasCcpInfo( 0, RasCompressionType.None, new RasCompressionOptions(NativeMethods.RASCCPO.None), RasCompressionType.None, new RasCompressionOptions(NativeMethods.RASCCPO.None)); Mock<IRasHelper> mock = new Mock<IRasHelper>(); RasHelper.Instance = mock.Object; mock.Setup(o => o.GetProjectionInfo(It.IsAny<RasHandle>(), NativeMethods.RASPROJECTION.Ccp)).Returns(expected); RasConnection target = new RasConnection(); RasCcpInfo actual = (RasCcpInfo)target.GetProjectionInfo(RasProjectionType.Ccp); Assert.AreSame(expected, actual); }