예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }