Example #1
0
        public void ExistentModify()
        {
            AuthorRepository authorRepository = new AuthorRepository();

            authorRepository.Add(AUTHOR);

            try
            {
                REPOSITORY.Add(PHRASE);
            }
            catch (AnalysisException) { }

            Author newAuthor = new Author("Seba", "Seba", "Gonzalez", new DateTime(1998, 3, 6));

            authorRepository.Add(newAuthor);

            PHRASE.Author = newAuthor;

            try
            {
                REPOSITORY.Modify(PHRASE.Id, PHRASE);
            }
            catch (AnalysisException) { }

            Assert.AreEqual(REPOSITORY.Get(PHRASE.Id).Author.Id, newAuthor.Id);
        }
Example #2
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 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 AddSentimentUpdatesPhrases()
        {
            PhraseRepository phraseRepository = new PhraseRepository();

            phraseRepository.Clear();

            AuthorRepository authorRepository = new AuthorRepository();

            authorRepository.Clear();

            authorRepository.Add(AUTHOR);

            Phrase    phrase    = new Phrase("i like google", DateTime.Now, AUTHOR);
            Sentiment sentiment = new Sentiment(SentimentType.POSITIVE, "i like");

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

            try
            {
                REPOSITORY.Add(sentiment);
            }
            catch (AnalysisException) { }

            Assert.AreEqual(sentiment.Type, phraseRepository.Get(phrase.Id).Type);
        }
        public void ModifySentimentNotUpdatePhraseWithoutType()
        {
            PhraseRepository phraseRepository = new PhraseRepository();
            AuthorRepository authorRepository = new AuthorRepository();

            Phrase    phrase    = new Phrase("i like google", DateTime.Now, AUTHOR);
            Sentiment sentiment = new Sentiment(SentimentType.POSITIVE, "i love");

            authorRepository.Add(AUTHOR);

            try
            {
                REPOSITORY.Add(sentiment);
            }
            catch (AnalysisException) { }

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

            SENTIMENT.Word = "i dont like";
            SENTIMENT.Type = SentimentType.NEGATIVE;

            REPOSITORY.Modify(sentiment.Id, SENTIMENT);

            Assert.IsNull(phraseRepository.Get(phrase.Id).Type);
        }
Example #6
0
        public void GetAllPhrases()
        {
            AuthorRepository authorRepository = new AuthorRepository();

            authorRepository.Add(AUTHOR);

            IList <Phrase> phrases = new List <Phrase>();

            Phrase firstPhrase  = new Phrase("i like", DateTime.Now, AUTHOR);
            Phrase secondPhrase = new Phrase("i dont like", DateTime.Now, AUTHOR);

            phrases.Add(firstPhrase);
            phrases.Add(secondPhrase);

            try
            {
                REPOSITORY.Add(firstPhrase);
            }
            catch (AnalysisException) { }

            try
            {
                REPOSITORY.Add(secondPhrase);
            }
            catch (AnalysisException) { }

            Assert.IsTrue(REPOSITORY.GetAll().SequenceEqual(phrases));
        }
Example #7
0
        public void Can_Update_Author()
        {
            // Arrange - update first name
            var author = new Author
            {
                AccountName = "glog",
                Description = "testing user",
                IsActivated = true
            };

            AuthorRepository.Add(author);

            // Arrange - activate status
            author.IsActivated = false;

            // Act
            var result = AuthorRepository.Update(author);

            // Arrange
            Assert.NotNull(result);
            Assert.False(result.IsActivated);

            // Arrange - update description
            author.Description = "new testing user";

            // Act
            result = AuthorRepository.Update(author);

            // Assert
            Assert.NotNull(result);
            Assert.Equal("new testing user", result.Description);
        }
Example #8
0
        public BookstoreMutation(AuthorRepository authorRepository, BookRepository bookRepository)
        {
            Field <AuthorType>("createAuthor",
                               arguments: new QueryArguments(new QueryArgument <NonNullGraphType <AuthorInputType> > {
                Name = "input"
            }),
                               resolve: context => {
                return(authorRepository.Add(context.GetArgument <Author>("input")));
            });
            Field <AuthorType>("updateAuthor",
                               arguments: new QueryArguments(
                                   new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            },
                                   new QueryArgument <NonNullGraphType <AuthorInputType> > {
                Name = "input"
            }
                                   ),
                               resolve: context => {
                var id     = context.GetArgument <long>("id");
                var author = context.GetArgument <Author>("input");
                return(authorRepository.Update(id, author));
            });
            Field <AuthorType>("deleteAuthor",
                               arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            }),
                               resolve: context => {
                return(authorRepository.Remove(context.GetArgument <long>("id")));
            });

            Field <BookType>("createBook",
                             arguments: new QueryArguments(new QueryArgument <NonNullGraphType <BookInputType> > {
                Name = "input"
            }),
                             resolve: context => {
                return(bookRepository.Add(context.GetArgument <Book>("input")));
            });
            Field <BookType>("updateBook",
                             arguments: new QueryArguments(
                                 new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            },
                                 new QueryArgument <NonNullGraphType <BookInputType> > {
                Name = "input"
            }
                                 ),
                             resolve: context => {
                var id   = context.GetArgument <long>("id");
                var book = context.GetArgument <Book>("input");
                return(bookRepository.Update(id, book));
            });
            Field <BookType>("deleteBook",
                             arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            }),
                             resolve: context => {
                return(bookRepository.Remove(context.GetArgument <long>("id")));
            });
        }
        private void AuthorMutations()
        {
            FieldAsync <AuthorType>("createAuthor",
                                    arguments: new QueryArguments(new QueryArgument <NonNullGraphType <AuthorInputType> > {
                Name = "input"
            }),
                                    resolve: async context => {
                return(await context.TryAsyncResolve(async c => await _authorRepository.Add(context.GetArgument <Author>("input"))));
            });

            FieldAsync <AuthorType>("updateAuthor",
                                    arguments: new QueryArguments(
                                        new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            },
                                        new QueryArgument <NonNullGraphType <AuthorInputType> > {
                Name = "input"
            }
                                        ),
                                    resolve: async context => {
                var id     = context.GetArgument <long>("id");
                var author = context.GetArgument <Author>("input");
                return(await context.TryAsyncResolve(async c => await _authorRepository.Update(id, author)));
            });

            FieldAsync <AuthorType>("deleteAuthor",
                                    arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IdGraphType> > {
                Name = "id"
            }),
                                    resolve: async context => {
                return(await context.TryAsyncResolve(async c => await _authorRepository.Remove(context.GetArgument <long>("id"))));
            });
        }
Example #10
0
        public void Cannot_Delete_NonExists_Author_From_DataSource()
        {
            // Arrange
            var author = new Author
            {
                AccountName = "glog",
                Description = "testing user",
                IsActivated = true
            };

            AuthorRepository.Add(author);

            var author2 = new Author
            {
                Id          = Guid.NewGuid(),
                AccountName = "glog2",
                Description = "testing user",
                IsActivated = true
            };

            // Act
            var result = AuthorRepository.Delete(author2);

            // Assert
            Assert.False(result);
            Assert.False(AuthorRepository.ProcessMessage.Success);
            Assert.Single(AuthorRepository.ProcessMessage.MessageList);
        }
Example #11
0
        public void Cannot_Add_Already_Existed_AccountName_To_DataSource()
        {
            // Arrange
            var authorExists = new Author
            {
                Id          = Guid.NewGuid(),
                AccountName = "glog",
                Description = "testing author",
                IsActivated = true
            };

            var author = new Author
            {
                AccountName = "glog",
                Description = "testing author",
                IsActivated = true
            };

            // Act
            AuthorRepository.Add(authorExists);
            var savedAuthor = AuthorRepository.Add(author);

            // Assert
            Assert.Null(savedAuthor);
            Assert.False(AuthorRepository.ProcessMessage.Success);
            Assert.Single(AuthorRepository.ProcessMessage.MessageList);
        }
Example #12
0
        public void Cannot_Update_Author_With_Duplicated_AccountName()
        {
            // Arrange
            var author = new Author
            {
                AccountName = "glog",
                Description = "testing user",
                IsActivated = true
            };

            AuthorRepository.Add(author);

            var user2 = new Author
            {
                AccountName = "glog2",
                Description = "testing user",
                IsActivated = true
            };

            AuthorRepository.Add(user2);

            author.AccountName = user2.AccountName;

            // Act
            var result = AuthorRepository.Update(author);

            // Assert
            Assert.Null(result);
            Assert.False(AuthorRepository.ProcessMessage.Success);
            Assert.Single(AuthorRepository.ProcessMessage.MessageList);
        }
Example #13
0
        public void GetById()
        {
            AuthorRepository repository = new AuthorRepository();

            repository.Add(AUTHOR);

            Assert.IsNotNull(repository.Get(AUTHOR.Id));
        }
Example #14
0
        public void NotEmpty()
        {
            AuthorRepository repository = new AuthorRepository();

            repository.Add(AUTHOR);

            Assert.IsFalse(repository.IsEmpty());
        }
Example #15
0
        public void AddAuthorFirstNameCorrectLength()
        {
            AuthorRepository repository = new AuthorRepository();
            Author           author     = new Author("sada", "aiii", "w", new DateTime(1990, 2, 3));

            repository.Add(author);
            Assert.IsFalse(repository.IsEmpty());
        }
Example #16
0
        public void AddAuthors(Authors item)
        {
            AuthorRepository repository = new AuthorRepository();

            //Gerar novo ID
            item.Id = Guid.NewGuid();
            repository.Add(item);
        }
Example #17
0
        public void AddPhraseSentimentNull()
        {
            AuthorRepository authorRepository = new AuthorRepository();

            authorRepository.Add(PHRASE.Author);

            REPOSITORY.Add(PHRASE);
        }
Example #18
0
        public void DeleteNonExistenceAuthor()
        {
            AuthorRepository repository = new AuthorRepository();
            Author           author     = new Author("sada", "sadasd", "sdaasd", new DateTime(1990, 2, 3));

            repository.Add(author);
            repository.Delete(author.Id);
            Assert.IsTrue(repository.IsEmpty());
        }
Example #19
0
        public void AddAuthorUserNameMaxLength()
        {
            AuthorRepository repository = new AuthorRepository();

            AUTHOR.Username = "******";
            repository.Add(AUTHOR);

            Assert.IsTrue(REPOSITORY.IsEmpty());
        }
Example #20
0
        public ActionResult Addauthors(Authors author)
        {
            AuthorRepository r = new AuthorRepository();

            r.Add(author);
            //listaCarti.Add(book);

            return(View("Succes"));
        }
Example #21
0
        private Guid CreateAuthor()
        {
            var author           = new Author("Eric Evans");
            var authorRepository = new AuthorRepository(GetContext());

            authorRepository.Add(author);
            authorRepository.SaveChanges();
            return(author.Id);
        }
Example #22
0
        public void AddAuthorFirstNameMaxLength()
        {
            AuthorRepository repository = new AuthorRepository();
            Author           author     = new Author("sada", "aeeeeeeeeeeeeeeeaa", "sdaasd", new DateTime(1990, 2, 3));

            repository.Add(author);

            Assert.IsTrue(repository.IsEmpty());
        }
        public void ModifySentimentNoUpdateDifferentSentimentTypeAlarm()
        {
            PhraseRepository      phraseRepository = new PhraseRepository();
            EntityRepository      entityRepository = new EntityRepository();
            AuthorRepository      authorRepository = new AuthorRepository();
            EntityAlarmRepository alarmRepository  = new EntityAlarmRepository();

            Phrase    phrase    = new Phrase("i like google", DateTime.Now, AUTHOR);
            Entity    google    = new Entity("google");
            Sentiment sentiment = new Sentiment(SentimentType.POSITIVE, "i like");

            authorRepository.Add(AUTHOR);

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

            try
            {
                entityRepository.Add(google);
            }
            catch (AnalysisException) { }

            try
            {
                phrase.AnalyzePhrase(new List <Entity> {
                    google
                }, new List <Sentiment> {
                    sentiment
                });
            }
            catch (AnalysisException) { }

            try
            {
                REPOSITORY.Add(sentiment);
            }
            catch (AnalysisException) { }

            SENTIMENT.Word = "i dont like";
            SENTIMENT.Type = SentimentType.NEGATIVE;

            REPOSITORY.Modify(sentiment.Id, SENTIMENT);

            EntityAlarm alarm = new EntityAlarm("1", "1", SentimentType.NEGATIVE, google);

            alarmRepository.Add(alarm);

            SENTIMENT.Word = "i really like";

            REPOSITORY.Modify(sentiment.Id, SENTIMENT);

            Assert.AreEqual(alarmRepository.Get(alarm.Id).PostCount, 0);
        }
Example #24
0
        public void DeleteAuthor()
        {
            AuthorRepository repository = new AuthorRepository();

            repository.Add(AUTHOR);

            repository.Delete(AUTHOR.Id);

            Assert.IsTrue(repository.IsEmpty());
        }
        static public void AddAnAuthor(Author newAuthor)
        {
            Author addAuthObject = new Author();

            addAuthObject.Aid       = newAuthor.Aid;
            addAuthObject.FirstName = newAuthor.FirstName;
            addAuthObject.LastName  = newAuthor.LastName;
            addAuthObject.BirthYear = newAuthor.BirthYear;
            _EAuthorRepo.Add(MapAuthor(addAuthObject).authorobj);
        }
Example #26
0
        public void AddAuthorBirthDateIncorrect()
        {
            AuthorRepository repository = new AuthorRepository();

            AUTHOR.Birthdate = new DateTime(1912, 12, 28);

            repository.Add(AUTHOR);

            Assert.IsTrue(REPOSITORY.IsEmpty());
        }
Example #27
0
        private void btnYazarEkle_Click(object sender, EventArgs e)
        {
            Author a = new Author();

            a.FirstName = txtYazarAdi.Text;
            a.LastName  = txtYazarSoyad.Text;
            ar.Add(a);
            AuthorList();
            AuthorCombo();
        }
Example #28
0
        public ActionResult Create([Bind(Include = "Id,Name,DateOfBirth,DateOfDeath")] Author author)
        {
            if (ModelState.IsValid)
            {
                db.Add(author);
                return(RedirectToAction("Index"));
            }

            return(View(author));
        }
Example #29
0
        public IActionResult Create(Author author)
        {
            if (ModelState.IsValid)
            {
                _authorRepository.Add(author);
                return(RedirectToAction("Index"));
            }

            return(View(author));
        }
Example #30
0
 public ActionResult AddAuthor(Author item)
 {
     if (arep.Any(x => x.Name == item.Name && x.LastName == item.LastName))
     {
         return(RedirectToAction("ListAuthors"));
     }
     else
     {
         arep.Add(item);
         return(RedirectToAction("ListAuthors"));
     }
 }