コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        /// <summary>
        /// Gets single steam profile by sending
        /// http request to steam web api.
        /// </summary>
        /// <param name="id64">64-bit steam id</param>
        protected virtual SteamProfileModel GetSteamProfileFromWebAPI(string id64, CToken token)
        {
            var apiResponse = _client.GetSteamAccountAsync(id64, token).Result;

            return(new SteamProfileModel(apiResponse)
            {
                AvatarFullBytes = GetProfilePic(apiResponse.AvatarFullURL),
                AvatarMediumBytes = GetProfilePic(apiResponse.AvatarMediumURL),
                AvatarSmallBytes = GetProfilePic(apiResponse.AvatarURL)
            });
        }
コード例 #4
0
        public void SingleFaultyId_ThrowsEmptyApiResponseException()
        {
            var response = SteamApiClient.GetSteamAccountAsync(0)
                           .Result;

            SleepAfterSendingRequest();

            Assert.False(response.Successful);
            Assert.NotNull(response.ThrownException);
            Assert.True(response.ThrownException is ApiEmptyResultException);
            Assert.Null(response.Contents);
        }
コード例 #5
0
        public void SingleId_ReturnsRequestedProfile()
        {
            var response = SteamApiClient.GetSteamAccountAsync(76561197960321706)
                           .Result;

            SleepAfterSendingRequest();

            Assert.True(response.Contents.Id64 == 76561197960321706);
            Assert.NotEmpty(response.Contents.PersonaName);
            Assert.NotEmpty(response.Contents.AvatarMediumURL);
            Assert.NotEmpty(response.Contents.AvatarFullURL);
            Assert.NotEmpty(response.Contents.AvatarSmallURL);
        }