public void Parse_Follower_Handle_Test() { #region Stubs var pattern = "@[email protected]"; #endregion var regex = ModerationRegexParser.Parse(ModerationEntityTypeEnum.Follower, pattern); #region Validations Assert.IsTrue(regex.IsMatch(pattern)); Assert.IsFalse(regex.IsMatch("@[email protected]")); Assert.IsFalse(regex.IsMatch("@[email protected]")); #endregion }
public void Parse_TwitterAccount_Simple_Test() { #region Stubs var pattern = "handle"; #endregion var regex = ModerationRegexParser.Parse(ModerationEntityTypeEnum.TwitterAccount, pattern); #region Validations Assert.IsTrue(regex.IsMatch(pattern)); Assert.IsFalse(regex.IsMatch("handles")); Assert.IsFalse(regex.IsMatch("andle")); #endregion }
public ModerationRepository(ModerationSettings settings) { var parsedFollowersWhiteListing = PatternsParser.Parse(settings.FollowersWhiteListing); var parsedFollowersBlackListing = PatternsParser.Parse(settings.FollowersBlackListing); var parsedTwitterAccountsWhiteListing = PatternsParser.Parse(settings.TwitterAccountsWhiteListing); var parsedTwitterAccountsBlackListing = PatternsParser.Parse(settings.TwitterAccountsBlackListing); _followersWhiteListing = parsedFollowersWhiteListing .Select(x => ModerationRegexParser.Parse(ModerationEntityTypeEnum.Follower, x)) .ToArray(); _followersBlackListing = parsedFollowersBlackListing .Select(x => ModerationRegexParser.Parse(ModerationEntityTypeEnum.Follower, x)) .ToArray(); _twitterAccountsWhiteListing = parsedTwitterAccountsWhiteListing .Select(x => ModerationRegexParser.Parse(ModerationEntityTypeEnum.TwitterAccount, x)) .ToArray(); _twitterAccountsBlackListing = parsedTwitterAccountsBlackListing .Select(x => ModerationRegexParser.Parse(ModerationEntityTypeEnum.TwitterAccount, x)) .ToArray(); // Set Follower moderation politic if (_followersWhiteListing.Any()) { _modMode.Add(ModerationEntityTypeEnum.Follower, ModerationTypeEnum.WhiteListing); } else if (_followersBlackListing.Any()) { _modMode.Add(ModerationEntityTypeEnum.Follower, ModerationTypeEnum.BlackListing); } else { _modMode.Add(ModerationEntityTypeEnum.Follower, ModerationTypeEnum.None); } // Set Twitter account moderation politic if (_twitterAccountsWhiteListing.Any()) { _modMode.Add(ModerationEntityTypeEnum.TwitterAccount, ModerationTypeEnum.WhiteListing); } else if (_twitterAccountsBlackListing.Any()) { _modMode.Add(ModerationEntityTypeEnum.TwitterAccount, ModerationTypeEnum.BlackListing); } else { _modMode.Add(ModerationEntityTypeEnum.TwitterAccount, ModerationTypeEnum.None); } }