public async Task <ForwardedTrafficResult> Value() { var response = await _userLocationService.LocationAsync(); return(response.Failure ? new ForwardedTrafficResult(false, false, string.Empty) : new ForwardedTrafficResult(true, _config.BlackHoleIps().Contains(response.Value.Ip), response.Value.Ip)); }
public async Task Detected_ShouldBe_WhenUserLocationService_Returns(string ip, bool expected) { // Arrange var response = ApiResponseResult <UserLocation> .Ok(new UserLocation { Ip = ip }); _vpnConfig.BlackHoleIps().Returns(new List <string> { "62.112.9.168", "104.245.144.186" }); _userLocationService.LocationAsync().Returns(response); var subject = new ForwardedTraffic(_userLocationService, _vpnConfig); // Act var result = await subject.Value(); // Assert result.Forwarded.Should().Be(expected); }