예제 #1
0
        public async Task OnTimerTick_ShouldCheck_ForwardedTraffic_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
            await _forwardedTraffic.Received(1).Value();

            await _blockedTraffic.DidNotReceive().Detected();
        }
예제 #2
0
        public async Task OnVpnStateChanged_ShouldStopTimer_WhenVpnStatus_IsNotConnected(VpnStatus status)
        {
            // Arrange
            P2PDetector detector = new P2PDetector(_logger, _appConfig, _blockedTraffic, _forwardedTraffic, _scheduler, _modals, _dialogs);
            await detector.OnVpnStateChanged(new VpnStateChangedEventArgs(VpnStatus.Connected, VpnError.None, "", false,
                                                                          VpnProtocol.Smart));

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

            // Assert
            _timer.IsEnabled.Should().BeFalse();
        }