Ejemplo n.º 1
0
        public void AddUpdateAlarm()
        {
            EntityRepository entityRepository = new EntityRepository();

            entityRepository.Add(ENTITITES.First(e => e.Name.Equals("Starbucks")));

            EntityAlarmRepository alarmRepository = new EntityAlarmRepository();
            EntityAlarm           alarm           = new EntityAlarm("1", "1", SentimentType.NEGATIVE, ENTITITES.First(e => e.Name.Equals("Starbucks")));

            alarmRepository.Add(alarm);

            SentimentRepository sentimentRepository = new SentimentRepository();

            sentimentRepository.Add(new Sentiment(SentimentType.NEGATIVE, "i dont like"));

            AuthorRepository authorRepository = new AuthorRepository();

            authorRepository.Add(AUTHOR);

            Phrase phrase = new Phrase("I dont like Starbucks", DateTime.Now, AUTHOR);

            REPOSITORY.Add(phrase);

            Assert.AreEqual(alarmRepository.Get(alarm.Id).PostCount, 1);
        }
        public void GetAllSentimentByType()
        {
            Sentiment firstPossitive = new Sentiment(SentimentType.POSITIVE, "i like");
            Sentiment secondPositive = new Sentiment(SentimentType.POSITIVE, "i love");
            Sentiment negative       = new Sentiment(SentimentType.NEGATIVE, "i hate");

            SentimentRepository repository = new SentimentRepository();

            repository.Add(firstPossitive);
            repository.Add(secondPositive);
            repository.Add(negative);

            IList <Sentiment> positiveRepository = repository.GetBySentimentType(SentimentType.POSITIVE);

            Assert.IsTrue(positiveRepository.Contains(firstPossitive) && positiveRepository.Contains(secondPositive));
        }
        public void ModifyUpdatePhrasesWithEntityNull()
        {
            Entity entity = new Entity("Microsoft");

            REPOSITORY.Add(entity);

            SentimentRepository sentimentRepository = new SentimentRepository();
            PhraseRepository    phraseRepository    = new PhraseRepository();
            AuthorRepository    authorRepository    = new AuthorRepository();

            authorRepository.Add(AUTHOR);

            try
            {
                sentimentRepository.Add(new Sentiment(SentimentType.POSITIVE, "i like"));
            }
            catch (AnalysisException) { }

            Phrase phrase = new Phrase("I like Uber", DateTime.Now, AUTHOR);

            try
            {
                phraseRepository.Add(phrase);
            }
            catch (AnalysisException) { }

            entity.Name = "Uber";

            REPOSITORY.Modify(entity.Id, entity);

            Assert.AreEqual(phraseRepository.Get(phrase.Id).Entity, entity);
        }
        public void GetById()
        {
            SentimentRepository repository = new SentimentRepository();

            repository.Add(SENTIMENT);

            Assert.IsNotNull(repository.Get(SENTIMENT.Id));
        }
        public void NotEmpty()
        {
            SentimentRepository repository = new SentimentRepository();

            repository.Add(SENTIMENT);

            Assert.IsFalse(repository.IsEmpty());
        }
        public void DeleteSentiment()
        {
            SentimentRepository repository = new SentimentRepository();

            repository.Add(SENTIMENT);

            repository.Delete(SENTIMENT.Id);

            Assert.IsTrue(repository.IsEmpty());
        }
        public void GetAllSentiments()
        {
            List <Sentiment> allSentiments = new List <Sentiment>();

            Sentiment firstPossitive = new Sentiment(SentimentType.POSITIVE, "i like");
            Sentiment secondPositive = new Sentiment(SentimentType.POSITIVE, "i love");
            Sentiment negative       = new Sentiment(SentimentType.NEGATIVE, "i hate");

            SentimentRepository repository = new SentimentRepository();

            repository.Add(firstPossitive);
            repository.Add(secondPositive);
            repository.Add(negative);

            allSentiments.Add(firstPossitive);
            allSentiments.Add(secondPositive);
            allSentiments.Add(negative);

            Assert.IsTrue(repository.GetAll().SequenceEqual(allSentiments));
        }
        public void ModifySentimentWord()
        {
            string newWord = "Me encanta";

            SentimentRepository repository = new SentimentRepository();

            repository.Add(SENTIMENT);

            SENTIMENT.Word = newWord;

            REPOSITORY.Modify(SENTIMENT.Id, SENTIMENT);

            Assert.AreEqual(repository.Get(SENTIMENT.Id).Word, newWord);
        }
        public void ModifySentimentType()
        {
            string        newWord = "Me disgusta";
            SentimentType newType = SentimentType.NEGATIVE;

            SentimentRepository repository = new SentimentRepository();

            repository.Add(SENTIMENT);

            SENTIMENT.Word = newWord;
            SENTIMENT.Type = newType;

            REPOSITORY.Modify(SENTIMENT.Id, SENTIMENT);

            Assert.AreEqual(repository.Get(SENTIMENT.Id).Type, (SentimentType)newType);
        }
        public void UpdateAlarmWithOldPhrases()
        {
            EntityRepository entityRepository = new EntityRepository();

            entityRepository.Add(ALARM.Entity);

            SentimentRepository sentimentRepository = new SentimentRepository();

            sentimentRepository.Add(new Sentiment(SentimentType.POSITIVE, "i like"));

            AuthorRepository authorRepository = new AuthorRepository();

            authorRepository.Add(AUTHOR);

            PhraseRepository phraseRepository = new PhraseRepository();

            phraseRepository.Add(new Phrase($"i like {ALARM.Entity.Name}", DateTime.Now.AddDays(-1), AUTHOR));

            REPOSITORY.Add(ALARM);

            Assert.AreEqual(REPOSITORY.Get(ALARM.Id).PostCount, 1);
        }
Ejemplo n.º 11
0
        public void UpdateAlarmWithOldPhrases()
        {
            SentimentRepository sentimentRepository = new SentimentRepository();

            sentimentRepository.Add(new Sentiment(SentimentType.POSITIVE, "i like"));

            AuthorRepository authorRepository = new AuthorRepository();

            authorRepository.Add(AUTHOR);

            PhraseRepository phraseRepository = new PhraseRepository();

            REPOSITORY.Add(ALARM);

            Phrase phraseTest = new Phrase($"i like Google", DateTime.Now, AUTHOR);

            try
            {
                phraseRepository.Add(phraseTest);
            }
            catch (AnalysisException) { }

            Assert.AreEqual(REPOSITORY.Get(ALARM.Id).PostCount, 1);
        }
        public void AddDuplicatedSentiment()
        {
            REPOSITORY.Add(SENTIMENT);

            REPOSITORY.Add(SENTIMENT);
        }