public void ValidUrl_GetsProfilePicAsByteArray(ulong id64)
        {
            var profile = SteamApiClient.GetSteamAccountAsync(id64)
                          .Result;

            SleepAfterSendingRequest();

            var smallPicBytes = SteamApiClient.GetProfilePicBytesAsync(profile.Contents.AvatarSmallURL)
                                .Result;

            SleepAfterSendingRequest(timeout: 0);

            var mediumPicBytes = SteamApiClient.GetProfilePicBytesAsync(profile.Contents.AvatarMediumURL)
                                 .Result;

            SleepAfterSendingRequest(timeout: 0);

            var fullPicBytes = SteamApiClient.GetProfilePicBytesAsync(profile.Contents.AvatarFullURL)
                               .Result;

            SleepAfterSendingRequest(timeout: 0);

            Assert.NotEmpty(smallPicBytes.Contents);
            Assert.NotEmpty(mediumPicBytes.Contents);
            Assert.NotEmpty(fullPicBytes.Contents);
        }
        public void InvalidFileName_ThrowsHttpRequestException()
        {
            var profile = SteamApiClient.GetSteamAccountAsync(76561197960321706)
                          .Result;

            SleepAfterSendingRequest();

            // Mess up the profile avatar URL
            if (profile.Contents.AvatarFullURL.Contains("jpg"))
            {
                profile.Contents.AvatarFullURL = profile.Contents.AvatarFullURL.Replace("jpg", "png");
            }
            else
            {
                profile.Contents.AvatarFullURL = profile.Contents.AvatarFullURL.Replace("png", "jpg");
            }

            var response = SteamApiClient.GetProfilePicBytesAsync(profile.Contents.AvatarFullURL)
                           .Result;

            SleepAfterSendingRequest();


            Assert.False(response.Successful);
            Assert.Null(response.Contents);
            Assert.NotNull(response.ThrownException);
            Assert.True(response.ThrownException is ApiResourceNotFoundException);
        }
        public void InvalidUrl_ThrowsEmptyResponseException()
        {
            var response = SteamApiClient.GetProfilePicBytesAsync("https://www.liibalaaba.com/pic.xf")
                           .Result;

            SleepAfterSendingRequest();

            Assert.False(response.Successful);
            Assert.Null(response.Contents);
            Assert.NotNull(response.ThrownException);
        }
예제 #4
0
 /// <summary>
 /// Gets image bytes by sending http request to url
 /// </summary>
 protected virtual byte[] GetProfilePic(string url) => _client.GetProfilePicBytesAsync(url)
 .Result;