Esempio n. 1
0
        public async Task OnVpnStateChanged_ShouldStopTimer_WhenVpnStatus_IsNotConnected(VpnStatus status)
        {
            // Arrange
            var detector = new P2PDetector(_logger, _appConfig, _blockedTraffic, _forwardedTraffic, _scheduler, _modals, _dialogs);
            await detector.OnVpnStateChanged(new VpnStateChangedEventArgs(VpnStatus.Connected, VpnError.None, "", false, VpnProtocol.Auto));

            // Act
            await detector.OnVpnStateChanged(new VpnStateChangedEventArgs(status, VpnError.None, "", false, VpnProtocol.Auto));

            // Assert
            _timer.IsEnabled.Should().BeFalse();
        }
Esempio n. 2
0
        public async Task OnTimerTick_ShouldShow_ForwardedTrafficModal_WhenPaidServer()
        {
            // Arrange
            _forwardedTraffic.Value().Returns(new ForwardedTrafficResult(true, true, string.Empty));
            P2PDetector detector = new P2PDetector(_logger, _appConfig, _blockedTraffic, _forwardedTraffic, _scheduler, _modals, _dialogs);
            await detector.OnVpnStateChanged(new VpnStateChangedEventArgs(VpnStatus.Connected, VpnError.None, PaidServer(), false));

            // Act
            _timer.Tick += Raise.Event();
            // Assert
            _modals.Received(1).Show <P2PForwardModalViewModel>();
        }
Esempio n. 3
0
        public async Task OnTimerTick_ShouldStopTimer_WhenBlockedTrafficDetected_OnFreeServer()
        {
            // Arrange
            _blockedTraffic.Detected().Returns(true);
            P2PDetector detector = new P2PDetector(_logger, _appConfig, _blockedTraffic, _forwardedTraffic, _scheduler, _modals, _dialogs);
            await detector.OnVpnStateChanged(new VpnStateChangedEventArgs(VpnStatus.Connected, VpnError.None, FreeServer(), false));

            // Act
            _timer.Tick += Raise.Event();
            // Assert
            _timer.IsEnabled.Should().BeFalse();
        }
Esempio n. 4
0
        public async Task OnTimerTick_ShouldShow_BlockedTrafficModal_WhenFreeServer()
        {
            // Arrange
            _blockedTraffic.Detected().Returns(true);
            P2PDetector detector = new P2PDetector(_logger, _appConfig, _blockedTraffic, _forwardedTraffic, _scheduler, _modals, _dialogs);
            await detector.OnVpnStateChanged(new VpnStateChangedEventArgs(VpnStatus.Connected, VpnError.None, FreeServer(), false));

            // Act
            _timer.Tick += Raise.Event();
            // Assert
            _dialogs.ReceivedWithAnyArgs(1).ShowWarning("");
        }
Esempio n. 5
0
        public async Task OnTimerTick_ShouldCheck_BlockedTraffic_WhenFreeServer()
        {
            // Arrange
            P2PDetector detector = new P2PDetector(_logger, _appConfig, _blockedTraffic, _forwardedTraffic, _scheduler, _modals, _dialogs);
            await detector.OnVpnStateChanged(new VpnStateChangedEventArgs(VpnStatus.Connected, VpnError.None, FreeServer(), false));

            // Act
            _timer.Tick += Raise.Event();
            // Assert
            await _blockedTraffic.Received(1).Detected();

            await _forwardedTraffic.DidNotReceive().Value();
        }
Esempio n. 6
0
        public async Task OnTimerTick_ShouldStopTimer_WhenBlockedTrafficDetected_OnPaidServer()
        {
            // Arrange
            _blockedTraffic.Detected().Returns(true);
            _forwardedTraffic.Value().Returns(new ForwardedTrafficResult(true, false, string.Empty));
            var detector = new P2PDetector(_logger, _appConfig, _blockedTraffic, _forwardedTraffic, _scheduler, _modals, _dialogs);
            await detector.OnVpnStateChanged(new VpnStateChangedEventArgs(VpnStatus.Connected, VpnError.None, PaidServer(), false, VpnProtocol.Auto));

            // Act
            _timer.Tick += Raise.Event();
            // Assert
            _timer.IsEnabled.Should().BeFalse();
        }
Esempio n. 7
0
        public async Task OnTimerTick_ShouldCheck_ForwardedTraffic_WhenPaidServer()
        {
            // Arrange
            _forwardedTraffic.Value().Returns(new ForwardedTrafficResult(true, true, string.Empty));
            var detector = new P2PDetector(_logger, _appConfig, _blockedTraffic, _forwardedTraffic, _scheduler, _modals, _dialogs);
            await detector.OnVpnStateChanged(new VpnStateChangedEventArgs(VpnStatus.Connected, VpnError.None, PaidServer(), false, VpnProtocol.Auto));

            // Act
            _timer.Tick += Raise.Event();
            // Assert
            await _forwardedTraffic.Received(1).Value();

            await _blockedTraffic.DidNotReceive().Detected();
        }