public void IsAtLeastOneAdapterAvailable_ShouldReturnFalseWhenNoAdaptersAvailable()
        {
            // Arrange
            _appSettings.NetworkAdapterType.Returns(OpenVpnAdapter.Tun);
            _networkInterfaceLoader.GetOpenVpnTunInterface().ReturnsNull();
            _networkInterfaceLoader.GetOpenVpnTapInterface().ReturnsNull();

            NetworkAdapterValidator sut = new(_networkInterfaceLoader, _appSettings);

            // Assert
            sut.IsAdapterAvailable().Should().BeFalse();
        }
Exemple #2
0
        public bool IsAdapterAvailable()
        {
            INetworkInterface openVpnTunInterface = _networkInterfaceLoader.GetOpenVpnTunInterface();
            INetworkInterface openVpnTapInterface = _networkInterfaceLoader.GetOpenVpnTapInterface();

            if (openVpnTunInterface == null && openVpnTapInterface == null)
            {
                return(false);
            }

            if (openVpnTunInterface == null && _appSettings.NetworkAdapterType == OpenVpnAdapter.Tun)
            {
                _appSettings.NetworkAdapterType = OpenVpnAdapter.Tap;
                SendTunFallbackEvent();
            }

            return(true);
        }