예제 #1
0
        public void AnalyzeUpdateCountDuplicateAuthors()
        {
            AuthorAlarm alarm = new AuthorAlarm("2", "2", SentimentType.POSITIVE, TimeMeasure.HOURS);

            Phrase firstPhrase  = new Phrase("I like google", DateTime.Now.AddHours(-1), AUTHOR);
            Phrase secondPhrase = new Phrase("I like starbucks", DateTime.Now.AddHours(-1), AUTHOR);

            try
            {
                firstPhrase.AnalyzePhrase(new List <Entity>(), new List <Sentiment> {
                    new Sentiment(SentimentType.POSITIVE, "I like")
                });
            }
            catch (AnalysisException) { }

            try
            {
                secondPhrase.AnalyzePhrase(new List <Entity>(), new List <Sentiment> {
                    new Sentiment(SentimentType.POSITIVE, "I like")
                });
            }
            catch (AnalysisException) { }

            alarm.AnalyzePhrases(new List <Phrase> {
                firstPhrase, secondPhrase
            });

            Assert.AreEqual(alarm.PostCount, 2);
        }
예제 #2
0
        public void IsNotEnabled()
        {
            AuthorAlarm alarm = new AuthorAlarm("2", "1", SentimentType.POSITIVE, TimeMeasure.HOURS);

            Phrase phrase = new Phrase("I like google", YESTERDAY, AUTHOR);

            try
            {
                phrase.AnalyzePhrase(new List <Entity>(), new List <Sentiment> {
                    new Sentiment(SentimentType.POSITIVE, "I like")
                });
            }
            catch (AnalysisException) { }

            alarm.AnalyzePhrases(new List <Phrase> {
                phrase
            });

            Assert.IsFalse(alarm.IsEnabled());
        }
예제 #3
0
        public void AnalyzeNoUpdatePostCount()
        {
            AuthorAlarm alarm = new AuthorAlarm("2", "1", SentimentType.NEGATIVE, TimeMeasure.DAYS);

            Phrase phrase = new Phrase("I like google", YESTERDAY.AddDays(-25), AUTHOR);

            try
            {
                phrase.AnalyzePhrase(new List <Entity>(), new List <Sentiment> {
                    new Sentiment(SentimentType.POSITIVE, "I like")
                });
            }
            catch (AnalysisException) { }

            alarm.AnalyzePhrases(new List <Phrase> {
                phrase
            });

            Assert.AreEqual(alarm.PostCount, 0);
        }