Exemplo n.º 1
0
        public FriendCollection GetFriends(Uri profileUrl)
        {
            var doc = DownloadContent(profileUrl, friendsPage);
            if (doc == null)
                return null;

            string username = GetUserNameFromDoc(doc);

            var friendsContainer = doc.SelectSingleNode("/friendsList/friends");

            var friendIds = GetFriendIdsFromPage(friendsContainer);

            var api = new SteamApi.SteamApiClient();
            api.Key = ConfigurationManager.AppSettings["Steam Api Key"];

            var friends = from friend in api.GetPlayerSummaries(friendIds.ToArray())
                          select new User
                          {
                              CommunityUrl = friend.ProfileUrl,
                              IconUrl = friend.AvatarMedium,
                              Id = friend.SteamId,
                              Username = friend.PersonaName,
                          };

            var toreturn = new FriendCollection(friends)
            {
                SteamId = username,
            };

            return toreturn;
        }
        public void InvalidSteamId()
        {
            var api = new SteamApi.SteamApiClient();

            api.Key = Constants.ValidApiKey;

            string userId = Constants.ValidSteamId;

            var response = api.GetPlayerSummaries(new[] { userId });

            Assert.IsNotNull(response);
            Assert.AreEqual(1, response.Length);

            var user = response[0];
            Assert.IsNotNull(user);
            Assert.AreEqual(userId, user.SteamId);
            Assert.AreEqual(CommunityVisibilityState.FriendsOfFriends, user.CommunityVisibilityState);
            //Assert.AreEqual(PersonaState.Offline, user.PersonaState);
            Assert.AreEqual(new Uri("http://steamcommunity.com/id/djeebus/"), user.ProfileUrl);
            Assert.IsNotNull(user.Avatar);
            Assert.IsNotNull(user.AvatarFull);
            Assert.IsNotNull(user.AvatarMedium);
            //Assert.AreEqual(0, user.LastLogOffTime);
            Assert.AreEqual("Joseph", user.RealName);
        }
Exemplo n.º 3
0
        public void InvalidApiKeyShouldThrowException()
        {
            var api = new SteamApi.SteamApiClient();

            api.Key = Constants.InvalidApiKey;

            var response = api.GetPlayerSummaries(new[] { Constants.InvalidSteamId });
        }