public void SetProfilePicture_TooFewWins() { var personalSetting = new PersonalSetting("peter#123"); var player = PlayerOverallStats.Create("peter#123"); for (int i = 0; i < 19; i++) { player.RecordWin(Race.HU, 1, true); } personalSetting.Players = new List <PlayerOverallStats> { player }; SetPictureCommand cmd1 = new SetPictureCommand() { avatarCategory = AvatarCategory.HU, pictureId = 1 }; personalSetting.SetProfilePicture(cmd1); SetPictureCommand cmd2 = new SetPictureCommand() { avatarCategory = AvatarCategory.HU, pictureId = 2 }; var profilePicture = personalSetting.SetProfilePicture(cmd2); Assert.IsFalse(profilePicture); Assert.AreEqual(AvatarCategory.HU, personalSetting.ProfilePicture.Race); Assert.AreEqual(1, personalSetting.ProfilePicture.PictureId); }
public async Task <bool> UpdatePicture(string battleTag, SetPictureCommand command) { var setting = await _personalSettingsRepository.Load(battleTag); if (setting == null) { var playerProfile = await _playerRepository.LoadPlayerProfile(battleTag); setting = new PersonalSetting(battleTag, new List <PlayerOverallStats> { playerProfile }); } var result = setting.SetProfilePicture(command); if (!result) { return(false); } await _personalSettingsRepository.Save(setting); return(true); }