protected override async Task <UserInformation> GetData() { using (var db = new Repository()) { var data = await db.GetUserInformation(_userToRetrieve); if (data != null) { if (data.Badges != null) { data.Badges.ToList().ForEach(x => x.Graphic = VoatPathHelper.BadgePath(x.Graphic, true, true)); } var moderates = db.GetSubversesUserModerates(_userToRetrieve); if (moderates != null) { data.Moderates = moderates.Select(x => new SubverseModerator() { Subverse = x.Subverse, Level = (ModeratorLevel)Enum.Parse(typeof(ModeratorLevel), x.Power.ToString()) }).ToList(); } } //TODO: Need to ensure this condition doesn't happen often, throwing exception to test. else { throw new VoatNotFoundException(String.Format("Can not find UserInformation for {0}", _userToRetrieve)); } return(data); } }
public void BadgePath() { //Badges don't use the CDN right now, only the UI string filename = "developer.jpg"; string result = ""; string domain = ConfigurationManager.AppSettings["ui.domain"]; domain = (String.IsNullOrEmpty(domain) ? "voat.co" : domain); result = VoatPathHelper.BadgePath(filename, false); Assert.AreEqual(String.Format("~/Graphics/Badges/{0}", filename), result, "Condition:1"); result = VoatPathHelper.BadgePath(filename, true, true); Assert.AreEqual(String.Format("https://{1}/Graphics/Badges/{0}", filename, domain), result, "Condition:2"); result = VoatPathHelper.BadgePath(filename, true, true); Assert.AreEqual(String.Format("https://{1}/Graphics/Badges/{0}", filename, domain), result, "Condition:3"); //Assert.Inconclusive(); }