示例#1
0
 public void Initialize()
 {
     Quote.Load();
     Users.Load();
     Location.Load();
     BannedWords.Load();
     CurrencyUsers.Load();
 }
        public void Test_FilterOutNegativeWords(string content, string[] words, string expected)
        {
            BannedWords bannedWords = new BannedWords();

            bannedWords.Content       = content;
            bannedWords.NegativeWords = words;

            Assert.AreEqual(expected, bannedWords.FilterOutNegativeWords());
        }
        public void Test_Story1(string content, string[] words, long expected)
        {
            BannedWords bannedWords = new BannedWords();

            bannedWords.Content       = content;
            bannedWords.NegativeWords = words;
            long badWords = bannedWords.SumOfBannedWords();

            Assert.AreEqual(expected, badWords);
        }
        public void Test_Story2(string[] negativeWords, string wordToAdd, string[] expected)
        {
            var mock = new Mock <INegativeWord>();

            mock.Setup(x => x.NegativeWordExistsInDatastore(It.IsAny <string>())).Returns(false);

            BannedWords bannedWords = new BannedWords();

            bannedWords.InsertNegativeWordIntoDatastore(wordToAdd);

            Assert.AreEqual(expected, bannedWords.RetrieveNegativeWordsFromDatastore());
        }
示例#5
0
        private bool ContainsBannedName(List <string> names)
        {
            foreach (var word in names.SelectMany(GetWordsFromName))
            {
                if (BannedWords.Contains(word, StringComparer.OrdinalIgnoreCase))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#6
0
        /// <summary>
        /// Add a word that gets the message deleted and user warned if they say it.
        /// </summary>
        /// <param name="serverId">The guild ID to look for</param>
        /// <param name="word">The word to ban.</param>
        public async static Task AddBannedWord(ulong serverId, string word)
        {
            using (SqliteDbContext DbContext = new SqliteDbContext())
            {
                try
                {
                    BannedWords Current = new BannedWords
                    {
                        Serverid = serverId,
                        Word     = word
                    };
                    DbContext.BannedWords.Add(Current);

                    await DbContext.SaveChangesAsync();
                }
                catch (Exception)
                { }
            }
        }
示例#7
0
        /// <summary>
        /// Remove a word from the banned word list
        /// </summary>
        /// <param name="serverId">The guild ID to look for</param>
        /// <param name="word">The word to remove.</param>
        public async static Task <bool> RemoveBannedWord(ulong serverId, string word)
        {
            using (SqliteDbContext DbContext = new SqliteDbContext())
            {
                try
                {   //Check if the guild has banned words
                    if (DbContext.BannedWords.Where(x => x.Serverid == serverId && x.Word == word).Count() < 1)
                    {
                        return(false);
                    }
                    else
                    {
                        BannedWords Current = DbContext.BannedWords.Where(x => x.Serverid == serverId && x.Word == word).FirstOrDefault();
                        DbContext.BannedWords.Remove(Current);
                    }
                    await DbContext.SaveChangesAsync();

                    return(true);
                }
                catch (Exception)
                { }
                return(false);
            }
        }
        public void Test_Story3(string word, string expected)
        {
            BannedWords bannedWords = new BannedWords();

            Assert.AreEqual(expected, bannedWords.FilterOutNegativeWord(word));
        }