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(); }
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>(); }
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(); }
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(""); }
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(); }
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(); }
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(); }