public void ProfilePageSortsProfilesByProfileID() { BuzzTwitterProfiles profiles = new BuzzTwitterProfiles(); profiles.Add(CreateNewProfile("D")); profiles.Add(CreateNewProfile("B")); profiles.Add(CreateNewProfile("A")); profiles.Add(CreateNewProfile("C")); List<String> profileIdsToSort = new List<string>(); foreach (var p in profiles) { profileIdsToSort.Add(p.ProfileId); } profileIdsToSort.Sort(); Assert.IsFalse(CompareProfileIds(profiles, profileIdsToSort)); profiles.Sort(); Assert.IsTrue(CompareProfileIds(profiles, profileIdsToSort)); }
private static bool CompareProfileIds(BuzzTwitterProfiles profiles, List<String> profileIdsToSort) { bool areEqual = true; for (int i = 0; i < profiles.Count; i++) { areEqual &= (profiles[i].ProfileId == profileIdsToSort[i]); } return areEqual; }
/// <summary> /// List of twitter profiles /// </summary> private void GenerateTwitterProfileListPageXml(BuzzTwitterProfiles twitterProfiles) { XmlNode profileList = AddElementTag(RootElement, "TWITTERPROFILELIST"); AddAttribute(profileList, "COUNT", twitterProfiles.Count); foreach (BuzzTwitterProfile profile in twitterProfiles) { XmlNode profileNode = null; profileNode = CreateElementNode("TWITTERPROFILE"); AddAttribute(profileNode, "SITETYPE", profile.SiteURL); AddTextTag(profileNode, "PROFILEID", profile.ProfileId); AddTextTag(profileNode, "ACTIVESTATUS", profile.Active.HasValue ? profile.Active.Value.ToString() : string.Empty); AddTextTag(profileNode, "TRUSTEDUSERSTATUS", profile.TrustedUsersEnabled.HasValue ? profile.TrustedUsersEnabled.Value.ToString() : string.Empty); AddTextTag(profileNode, "PROFILECOUNTSTATUS", profile.ProfileCountEnabled.HasValue ? profile.ProfileCountEnabled.Value.ToString() : string.Empty); AddTextTag(profileNode, "PROFILEKEYWORDCOUNTSTATUS", profile.ProfileKeywordCountEnabled.HasValue ? profile.ProfileKeywordCountEnabled.Value.ToString(): string.Empty); AddTextTag(profileNode, "MODERATIONSTATUS", profile.ModerationEnabled.HasValue ? profile.ModerationEnabled.Value.ToString() : string.Empty); profileList.AppendChild(profileNode); } }
/// <summary> /// Integration with the BuzzApi and retrieves twitter profiles /// </summary> /// <returns></returns> private BuzzTwitterProfiles GenerateProfileList() { BuzzClient client; BuzzTwitterProfiles tweetProfiles = new BuzzTwitterProfiles(); var response = string.Empty; try { client = new BuzzClient(); tweetProfiles = client.GetProfiles(); } catch (Exception ex) { InputContext.Diagnostics.WriteExceptionToLog(ex); BaseResult result = new Error { Type = "PROFILELISTFILTERACTION", ErrorMessage = "Buzz returns an error. Please try again." + ex.Message }; } return tweetProfiles; }
/// <summary> /// Filter twitter profiles based on the site list /// </summary> /// <param name="profileList"></param> /// <param name="siteIdList"></param> /// <returns></returns> private BuzzTwitterProfiles GenerateUserSpecificProfileList(BuzzTwitterProfiles profileList, List<int> siteIdList) { BuzzTwitterProfiles filteredProfileList = new BuzzTwitterProfiles(); foreach (int siteId in siteIdList) { foreach (BuzzTwitterProfile profile in profileList) { if(false == string.IsNullOrEmpty(profile.SiteURL) && profile.SiteURL.Equals(InputContext.TheSiteList.GetSite(siteId).SiteName)) { filteredProfileList.Add(profile); } } } return filteredProfileList; }
/// <summary> /// Filter twitter profiles based on the site /// </summary> /// <param name="profileList"></param> /// <param name="siteType"></param> /// <returns></returns> private BuzzTwitterProfiles GetSiteSpecificProfileList(BuzzTwitterProfiles profileList, string siteType) { BuzzTwitterProfiles filteredProfileList = new BuzzTwitterProfiles(); foreach (BuzzTwitterProfile profile in profileList) { if (false == string.IsNullOrEmpty(profile.SiteURL) && profile.SiteURL.Equals(siteType)) { filteredProfileList.Add(profile); } } return filteredProfileList; }
/// <summary> /// Filtered profile list based on the site type /// </summary> /// <param name="profileList">BuzzTwitterProfiles</param> /// <param name="siteType">BuzzSiteType</param> /// <returns></returns> private BuzzTwitterProfiles ProcessCommand(BuzzTwitterProfiles profileList, string siteType) { BuzzTwitterProfiles filteredProfileList = new BuzzTwitterProfiles(); //Get active only profiles if (_activeOnly.ToUpper().Equals("ON")) { foreach (BuzzTwitterProfile profile in profileList) { if (true == profile.Active.Value) { filteredProfileList.Add(profile); } } if (false == string.IsNullOrEmpty(siteType) && false == siteType.ToUpper().Equals("ALL")) { filteredProfileList = GetSiteSpecificProfileList(filteredProfileList, siteType); } } else { filteredProfileList = profileList; if (false == string.IsNullOrEmpty(_siteType) && false == siteType.ToUpper().Equals("ALL")) { filteredProfileList = GetSiteSpecificProfileList(filteredProfileList, siteType); } } return filteredProfileList; }