From 2f6b3445dd6dcd26e5e50348dbf7a8abd480ac7d Mon Sep 17 00:00:00 2001 From: kazbekovruslan Date: Wed, 29 May 2024 20:40:38 +0300 Subject: [PATCH] add minicrawler tests --- Homework7/MiniCrawler.Tests/Tests.fs | 34 +++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/Homework7/MiniCrawler.Tests/Tests.fs b/Homework7/MiniCrawler.Tests/Tests.fs index 5612e94..c9e9006 100644 --- a/Homework7/MiniCrawler.Tests/Tests.fs +++ b/Homework7/MiniCrawler.Tests/Tests.fs @@ -5,4 +5,36 @@ open FsUnit open NUnit.Framework [] -let Test () = Assert.Pass() +let ``extractLinks should test`` () = + let url = "https://example.com" + + async { + let! htmlPage = downloadPageAsync url + let actualLinks = extractLinks htmlPage + let expectedLinks = [ "https://www.iana.org/domains/example" ] + Assert.AreEqual(expectedLinks, actualLinks) + } + +[] +let ``downloadPages test`` () = + let url = "https://se.math.spbu.ru" + + async { + let! actual = downloadPages url + printfn "%A" actual + + let expected = + [ ("https://spbu.ru/", 112326) + ("https://oops.math.spbu.ru/SE/alumni", 49175) + ("https://ru.wikipedia.org/wiki/%D0%A2%D0%B5%D1%80%D0%B5%D1%85%D0%BE%D0%B2,_%D0%90%D0%BD%D0%B4%D1%80%D0%B5%D0%B9_%D0%9D%D0%B8%D0%BA%D0%BE%D0%BB%D0%B0%D0%B5%D0%B2%D0%B8%D1%87", + 102683) + ("https://ru.wikipedia.org/wiki/%D0%A2%D0%B5%D1%80%D0%B5%D1%85%D0%BE%D0%B2,_%D0%90%D0%BD%D0%B4%D1%80%D0%B5%D0%B9_%D0%9D%D0%B8%D0%BA%D0%BE%D0%BB%D0%B0%D0%B5%D0%B2%D0%B8%D1%87", + 102683) + ("https://www.acm.org/binaries/content/assets/education/curricula-recommendations/cc2005-march06final.pdf", + 758040) + ("https://t.me/sysprog_admission", 12477) + ("https://oops.math.spbu.ru/SE", 23408) + ("https://oops.math.spbu.ru/SE/alumni", 49175) ] + + Assert.AreEqual(expected, actual) + }