public void DownloadProfileContentTest() { BattleNetProfile target; target = new BattleNetProfile( @"http://eu.battle.net/sc2/ru/profile/267901/1/Zakk/" ); Assert.IsTrue( target.DownloadProfileContent() ); Assert.AreNotEqual( "", target.ProfileContent ); }
public void GetAchievementPointsTest() { BattleNetProfile target; target = new BattleNetProfile( @"http://eu.battle.net/sc2/ru/profile/267901/1/Zakk/" ); target.DownloadData(); Assert.AreEqual( 2390, target.GetAchievementPoints() ); Assert.AreEqual( 2390, target.AchievementPoints ); Assert.AreEqual( target.GetAchievementPoints(), target.AchievementPoints ); }
public ActionResult Edit(FormCollection collection) { try { var profile = profileRepository.GetProfile( profileRepository.GetUserId( User.Identity.Name ) ); profile.first_name = Request.Form["first_name"]; profile.last_name = Request.Form["last_name"]; profile.details = Request.Form["details"]; profile.country_id = Convert.ToInt32( Request.Form["country_id"] ); var profileUrl = Request.Form["profile_url"]; if (!String.IsNullOrEmpty( profileUrl )) { var bnetProfile = new BattleNetProfile( profileUrl ); if (!bnetProfile.IsValidUrl()) return RedirectToAction( "Edit" ); bnetProfile.DownloadData(); profile.profile_url = profileUrl; profile.bnet_name = bnetProfile.GetPlayerName(); profile.bnet_server = bnetProfile.GetServer(); profile.league = bnetProfile.GetLeague(); profile.race = bnetProfile.GetRace(); profile.avatar_style = bnetProfile.GetPortraitHtmlStyle( @"/Content/img/bnet/" ); profile.achievements = bnetProfile.GetAchievementPoints(); profile.rank = bnetProfile.GetRank(); bnetProfile.GetStats(); profile.points = bnetProfile.Points; profile.wins = Convert.ToInt32( bnetProfile.Wins ); profile.loses = Convert.ToInt32( bnetProfile.Loses ); profile.win_rate = bnetProfile.Percent; profile.synchronized_at = DateTime.UtcNow; } else { profile.profile_url = ""; } profileRepository.Save(); return RedirectToAction( "" ); } catch { return View(); } }
public void GetPlayerNameTest() { BattleNetProfile target; target = new BattleNetProfile( @"http://eu.battle.net/sc2/ru/profile/267901/1/Zakk/" ); Assert.AreEqual( "Zakk", target.GetPlayerName(), true ); }
public void GetLeagueTest() { BattleNetProfile target; target = new BattleNetProfile( @"http://eu.battle.net/sc2/ru/profile/267901/1/Zakk/" ); target.DownloadData(); Assert.AreEqual( "diamond_1", target.GetLeague(), true ); }
public void IsValidUrlTest() { BattleNetProfile target; target = new BattleNetProfile( @"http://eu.battle.net/sc2/ru/profile/267901/1/Zakk/" ); Assert.IsTrue( target.IsValidUrl() ); target = new BattleNetProfile( @"http://us.battle.net/sc2/en/profile/289433/1/AlLaboUtyOu/" ); Assert.IsTrue( target.IsValidUrl() ); target = new BattleNetProfile( @"http://kr.battle.net/sc2/ko/profile/106432/1/SoundWeRRa/" ); Assert.IsTrue( target.IsValidUrl() ); target = new BattleNetProfile( @"http://gmail.com" ); Assert.IsFalse( target.IsValidUrl() ); target = new BattleNetProfile( @"http://us.battle.net/sc2/en/profile/2894d33/1/AlLaboUtyO1u/" ); Assert.IsFalse( target.IsValidUrl() ); target = new BattleNetProfile( @"" ); Assert.IsFalse( target.IsValidUrl() ); }
public void GetStatsTest() { BattleNetProfile target; target = new BattleNetProfile( @"http://eu.battle.net/sc2/ru/profile/267901/1/Zakk/" ); target.DownloadData(); target.GetStats(); Assert.AreEqual( 14, target.Points ); Assert.AreEqual( 2, target.Wins ); }
public void GetRankTest() { BattleNetProfile target; target = new BattleNetProfile( @"http://eu.battle.net/sc2/ru/profile/267901/1/Zakk/" ); target.DownloadData(); Assert.AreEqual( 57, target.GetRank() ); }
public ActionResult ReloadBnetData( String username ) { var userProfile = userRepository.GetUserProfile( username ); if (String.IsNullOrEmpty( userProfile.profile_url )) return Json( new {result = "profile_url_is_empty"}, JsonRequestBehavior.AllowGet ); var bnetProfile = new BattleNetProfile( userProfile.profile_url ); if (!bnetProfile.IsValidUrl()) return Json( new { result = "profile_url_is_empty" }, JsonRequestBehavior.AllowGet ); bnetProfile.DownloadData(); userProfile.race = bnetProfile.GetRace(); userProfile.bnet_name = bnetProfile.GetPlayerName(); userProfile.bnet_server = bnetProfile.GetServer(); userProfile.league = bnetProfile.GetLeague(); userProfile.avatar_style = bnetProfile.GetPortraitHtmlStyle( @"/Content/img/bnet/" ); userProfile.achievements = bnetProfile.GetAchievementPoints(); userProfile.rank = bnetProfile.GetRank(); bnetProfile.GetStats(); userProfile.points = bnetProfile.Points; userProfile.wins = Convert.ToInt32( bnetProfile.Wins ); userProfile.loses = Convert.ToInt32( bnetProfile.Loses ); userProfile.win_rate = bnetProfile.Percent; userProfile.synchronized_at = DateTime.UtcNow; userRepository.Save(); return Json( new { result = "ok" }, JsonRequestBehavior.AllowGet ); }