public int Refresh() { ParserRutor parserRutor = new ParserRutor(); List <FoundPost> foundPosts = parserRutor.GetList(); DataBaseControl dataBase = new DataBaseControl(); List <FoundPost> oldFoundPosts = dataBase.GetLastFounded(TTrakers.Rutor, 500); foundPosts = parserRutor.DeleteDuplicateFromList(oldFoundPosts, foundPosts); List <ReadyPost> readyPosts = parserRutor.GetItems(foundPosts); int result = dataBase.AddReady(readyPosts); return(result); }
public void StartGetListTest() { ParserRutor parser = new ParserRutor(); List <FoundPost> actual = null; bool eventCall = false; parser.FoundPostsReceived += delegate(object s, FoundPostArgs e) { actual = e.FoundPosts; eventCall = true; }; parser.StartGetList(); CommonFunction.SleepTimer(12, ref eventCall); Assert.IsNotNull(actual); }
public void StartGetItemTest() { ParserRutor parser = new ParserRutor(); ReadyPost actual = null; bool eventCall = false; DataBaseControl db = new DataBaseControl(); List <FoundPost> list = db.GetLastFounded(TTrakers.Rutor, 10); FoundPost itemList = list.First(); parser.ReadyPostsReceived += delegate(object s, ReadyPostArgs e) { actual = e.ReadyPostRecieved; eventCall = true; }; parser.StartGetItem(itemList); CommonFunction.SleepTimer(12, ref eventCall); Assert.IsNotNull(actual); }
public void AddFoundedsTest() { List <FoundPost> listFound = null; bool eventCall = false; ParserRutor parser = new ParserRutor(); parser.FoundPostsReceived += delegate(object s, FoundPostArgs e) { listFound = e.FoundPosts; eventCall = true; }; parser.StartGetList(); CommonFunction.SleepTimer(12, ref eventCall); DataBaseControl db = new DataBaseControl(); int actual = db.AddFoundeds(listFound); Assert.IsNotNull(listFound); Assert.AreEqual(listFound.Count(), actual); }
public void StartGetListTest() { ParserRutor parser = new ParserRutor(); List <ItemList> actual = null; bool eventCall = false; parser.ListReceived += delegate(object s, ItemListArgs e) { actual = e.Posts; eventCall = true; }; parser.StartGetList(); // ждем 12 секунд, если событие выполниться, идем дальше for (int countCall = 0; countCall < 48 && !eventCall; countCall++) { Thread.Sleep(250); } Assert.IsNotNull(actual); }
public void DeleteDuplicateFromListTest() { ParserRutor parser = new ParserRutor(); List <FoundPost> newPost = null; bool eventCall = false; parser.FoundPostsReceived += delegate(object s, FoundPostArgs e) { newPost = e.FoundPosts; eventCall = true; }; parser.StartGetList(); CommonFunction.SleepTimer(12, ref eventCall); Assert.IsNotNull(newPost); DataBaseControl dataBase = new DataBaseControl(); List <FoundPost> oldPost = dataBase.GetLastFounded(TTrakers.Rutor); List <FoundPost> actual = parser.DeleteDuplicateFromList(oldPost, newPost); Assert.Fail(); }
public void AddReadyTest() { autoParsingContext db = new autoParsingContext(); FoundPost foundPost = db.FoundPost.First(); ReadyPost readyPost = null; bool eventCall = false; ParserRutor parserRutor = new ParserRutor(); parserRutor.ReadyPostsReceived += delegate(object s, ReadyPostArgs e) { readyPost = e.ReadyPostRecieved; eventCall = true; }; parserRutor.StartGetItem(foundPost); CommonFunction.SleepTimer(12, ref eventCall); DataBaseControl dataBaseControl = new DataBaseControl(); Assert.IsNotNull(readyPost); int actual = dataBaseControl.AddReady(readyPost); Assert.AreEqual(9, actual); }