Esempio n. 1
0
        public async Task TestGuestUserPost(string url)
        {
            var parser = new ThreadParser(new NetcupThreadInfo(), new NetcupPostInfo(), new NetcupUserInfo(), new NetcupSearchInfo());
            var thread = await parser.ParseThreadAsync(new Uri(url), 30, 30);

            Assert.Contains(thread.Posts, v => v.IsGuestPost && string.IsNullOrEmpty(v.GuestUsername) == false);
        }
Esempio n. 2
0
        private static void Crawl(string url, string path)
        {
            var parser = new ThreadParser(new NetcupThreadInfo(), new NetcupPostInfo(), new NetcupUserInfo(), new NetcupSearchInfo());

            var task = Task.Run(async() =>
            {
                var thread = await parser.ParseThreadAsync(new Uri(url));
                thread.Serialize(new FileInfo(path));
            });

            Task.WaitAll(task);
        }
Esempio n. 3
0
        public async Task TestPostParser(string url, uint page, uint postuid, bool haslikes, bool hassiganture, bool hasuser)
        {
            var parser = new ThreadParser(new NetcupThreadInfo(), new NetcupPostInfo(), new NetcupUserInfo(), new NetcupSearchInfo());
            var thread = await parser.ParseThreadAsync(new Uri(url.Substring(0, url.IndexOf('#'))), page, page);

            var post = thread.Posts.Where(v => v.Uid == postuid).Single();

            Assert.Equal <uint>(postuid, post.Uid);
            Assert.Equal(url, post.Url);
            Assert.True(haslikes ? (post.LikeCount > 0) : true);
            Assert.True(post.DislikeCount < 1);
            Assert.Equal <bool>(hasuser, post.User != null);
            Assert.Equal <bool>(hassiganture, !string.IsNullOrEmpty(post.User?.SignatureHtml));
        }
Esempio n. 4
0
        public async Task TestParseThread(string teststr)
        {
            var parser = new ThreadParser(new NetcupThreadInfo(), new NetcupPostInfo(), new NetcupUserInfo(), new NetcupSearchInfo());
            var thread = await parser.ParseThreadAsync(new Uri(teststr), 1, 3);

            var postUsers      = thread.Posts.Where(v => v.User != null).Select(v => v.User).Distinct();
            var userIntersects = thread.Users.Users.Intersect(postUsers);

            Assert.Equal("https://forum.netcup.de/sonstiges/smalltalk/1051-das-l%C3%A4ngste-thema/", thread.StartpageUrl);
            Assert.True(thread.PageCount >= 383);
            Assert.True(thread.CurrentPageNo <= thread.PageCount && thread.CurrentPageNo >= 1);
            Assert.True(thread.Uid > 0);
            Assert.True(thread.Posts.Count > 0);
            Assert.True(thread.Users.Users.Count > 0);
            Assert.Equal <int>(postUsers.Count(), userIntersects.Count());
        }