コード例 #1
0
ファイル: ApiServers.cs プロジェクト: mauroxdev/win-app
        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]);
        }
コード例 #2
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);
        }
コード例 #3
0
        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");
        }