public async Task <IReadOnlyCollection <LogicalServerContract> > GetServersAsync() { try { var response = await _apiClient.GetServersAsync(_location.Ip()); if (response.Success) { return(response.Value.Servers); } } catch (HttpRequestException ex) { _logger.Error("API: Get servers failed: " + ex.CombinedMessage()); } return(new LogicalServerContract[0]); }
public void Value_ShouldBeEmpty_WhenIpIsEmpty() { // Arrange var userLocation = new UserLocation(string.Empty, 10.0f, 10.0f, "ISP", "ZZ"); _userStorage.Location().Returns(userLocation); var location = new TruncatedLocation(_userStorage); // Act var result = location.Ip(); // Assert result.Should().Be(string.Empty); }
public void Value_ShouldBe_IpWithZeroedLastOctet(string ip) { // Arrange var userLocation = new UserLocation(ip, 10.0f, 10.0f, "ISP", "ZZ"); _userStorage.Location().Returns(userLocation); var location = new TruncatedLocation(_userStorage); // Act var result = location.Ip(); // Assert result.Split('.')[3].Should().Be("0"); }