Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maforget committed Mar 28, 2024
1 parent f4c0f09 commit c9e1fe0
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 15 deletions.
41 changes: 38 additions & 3 deletions Tests/AmazonBookTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void TestGetBook()
Assert.AreEqual("Rob Guillory", book.Writer);//Author
Assert.AreEqual("Rob Guillory, Taylor Wells", book.CoverArtist);
Assert.AreEqual("Rob Guillory, Taylor Wells", book.Penciller);//Artists
Assert.AreEqual(0.0f, book.BookPrice);
Assert.AreEqual(-1f, book.BookPrice);
}

[TestMethod]
Expand Down Expand Up @@ -103,7 +103,7 @@ public void TestGetBook4()
Assert.AreEqual(@"https://www.amazon.com/dp/B07X5N41P8", book.Web);
Assert.AreEqual("Rob Guillory", book.Writer);//Author
Assert.AreEqual("Rob Guillory", book.Penciller);//Contributor
Assert.AreEqual(10.99f, book.BookPrice);
Assert.AreEqual(11.99f, book.BookPrice);
}

[TestMethod]
Expand All @@ -123,7 +123,7 @@ public void TestGetBook5()
Assert.AreEqual(2019, book.Year);
Assert.AreEqual("en", book.LanguageISO);
Assert.AreEqual("DC", book.Publisher);
Assert.AreEqual(4.5f, book.CommunityRating);
Assert.AreEqual(4.6f, book.CommunityRating);
Assert.AreEqual(@"https://www.amazon.com/dp/B07VVTGY3Z", book.Web);
Assert.AreEqual("Joshua Williamson", book.Writer);//Author
Assert.AreEqual("David Marquez", book.Penciller);
Expand Down Expand Up @@ -229,5 +229,40 @@ public void TestGetBook9()
Assert.AreEqual("Sebastian Piriz", book.Penciller);
Assert.AreEqual(1.99f, book.BookPrice);
}

[TestMethod]
public void TestGetBook10()
{
var link = new AmazonLinkIssues("B0CQLL8R8H");
var book = link.ScrapeData();

Assert.AreEqual("I Hate Fairyland Vol. 6", book.Title);
Assert.AreEqual(@"Death by a thousand Gerts! King Cloudeus is determined to finish what his sister Queen Cloudia never could: kick Gert out of Fairyland FOR GOOD! And the only way to do that is have every Gert who ever lived battle each other to the death. Who said there's only so many Gerts to go around?! They clearly haven't read this comic. OG Gert returns to find the last key to escape, but is it too late, and will she become a Lifetime Citizen of Fairyland? Eisner Award-winning writer SKOTTIE YOUNG (MIDDLEWEST, TWIG, THE ME YOU LOVE IN THE DARK) and artist BRETT BEAN (Marvel’s Rocket and Groot) are back in the triumphant return to I HATE FAIRYLAND! Collects I HATE FAIRYLAND (2022) #6-10", book.Summary);
Assert.AreEqual("Scraped metadata from Amazon [B0CQLL8R8H].", book.Notes);
Assert.AreEqual("I Hate Fairyland", book.Series);
Assert.AreEqual("6", book.Number);
Assert.AreEqual(17, book.Day);
Assert.AreEqual(1, book.Month);
Assert.AreEqual(2024, book.Year);
Assert.AreEqual("en", book.LanguageISO);
Assert.AreEqual("Image", book.Publisher);
//Assert.AreEqual(4.3f, book.CommunityRating);
Assert.AreEqual(@"https://www.amazon.com/dp/B0CQLL8R8H", book.Web);
Assert.AreEqual("Skottie Young", book.Writer);//Author
Assert.AreEqual("Skottie Young", book.Penciller);//Artist
Assert.AreEqual("Brett B Bean", book.CoverArtist);
Assert.AreEqual(13.99f, book.BookPrice);
}

[TestMethod]
public void TestGetBook11()
{
var link = new AmazonLinkIssues("1779524692");
var book = link.ScrapeData();

Assert.AreEqual(27, book.Day);
Assert.AreEqual(2, book.Month);
Assert.AreEqual(2024, book.Year);
}
}
}
6 changes: 3 additions & 3 deletions Tests/AmazonLinkSerieTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void TestSeriesGetIssues2()
{
var amazonLink = new AmazonLinkSerie("B0932GH6NJ");
var issues = amazonLink.GetIssues();//From the collections View
var thirdIssue = issues[2];
var thirdIssue = issues[1];

Assert.AreEqual("B08TSN4GCN", thirdIssue.ASIN);
Assert.AreEqual("Usagi Yojimbo Saga Volume 2 (Second Edition)", thirdIssue.Title);
Expand All @@ -56,7 +56,7 @@ public void TestSeriesGetIssues2()
Assert.IsNull(thirdIssue.SerieInfo.RawText);
Assert.AreEqual("Usagi Yojimbo Saga", thirdIssue.SerieInfo.Serie);
Assert.AreEqual("2", thirdIssue.SerieInfo.Number);
Assert.AreEqual(9, thirdIssue.SerieInfo.Count);
Assert.AreEqual(8, thirdIssue.SerieInfo.Count);
}

[TestMethod]
Expand All @@ -76,7 +76,7 @@ public void TestLongSeries()
Assert.IsNull(fortyIssue.SerieInfo.RawText);
Assert.AreEqual("40", fortyIssue.SerieInfo.Number);
Assert.AreEqual("Saga", fortyIssue.SerieInfo.Serie);
Assert.AreEqual(64, fortyIssue.SerieInfo.Count);
Assert.AreEqual(66, fortyIssue.SerieInfo.Count);
}

[TestMethod]
Expand Down
12 changes: 6 additions & 6 deletions Tests/AmazonLinkTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void TestLinks()
Assert.AreEqual($@"https://www.amazon.com/dp/{asin}", amazonLink.Link);

var serieASIN = "B07JJ7S3BR";
var serieText = "Book 16 of 19: Farmhand";
var serieText = "Book 16 of 20: Farmhand";
var serieLink = $"dp/{serieASIN}?binding=kindle_edition&ref_=dbs_s_ks_series_rwt_tkin&sr=1-18";
var linkSerie = new AmazonLinkSerie(serieText, serieLink);
amazonLink.SerieInfo = SerieInfo.Parse(serieText, title, linkSerie);
Expand All @@ -29,10 +29,10 @@ public void TestLinks()
Assert.AreEqual($@"https://www.amazon.com/dp/{serieASIN}", amazonLink.SerieInfo.SerieLink.Link);
Assert.AreEqual("Farmhand", amazonLink.SerieInfo.Serie);

Assert.AreEqual("Farmhand (16 of 19 book series)", amazonLink.SerieDisplayText);
Assert.AreEqual("Farmhand (16 of 20 book series)", amazonLink.SerieDisplayText);
Assert.AreEqual(serieText, amazonLink.SerieInfo.RawText);
Assert.AreEqual("16", amazonLink.SerieInfo.Number);
Assert.AreEqual(19, amazonLink.SerieInfo.Count);
Assert.AreEqual(20, amazonLink.SerieInfo.Count);
}

[TestMethod]
Expand All @@ -50,7 +50,7 @@ public void TestLinks2()
Assert.AreEqual(imageLink, amazonLink.ImageLink);

var serieASIN = "B07JJ7S3BR";
var serieText = "Book 1 of 19: Farmhand";
var serieText = "Book 1 of 20: Farmhand";
var serieLink = $"dp/{serieASIN}?binding=kindle_edition&ref_=dbs_s_ks_series_rwt_tkin&sr=1-18";
var linkSerie = new AmazonLinkSerie(serieText, serieLink);
amazonLink.SerieInfo = SerieInfo.Parse(serieText, title, linkSerie);
Expand All @@ -59,10 +59,10 @@ public void TestLinks2()
Assert.AreEqual($@"https://www.amazon.com/dp/{serieASIN}", amazonLink.SerieInfo.SerieLink.Link);
Assert.AreEqual("Farmhand", amazonLink.SerieInfo.Serie);

Assert.AreEqual("Farmhand (1 of 19 book series)", amazonLink.SerieDisplayText);
Assert.AreEqual("Farmhand (1 of 20 book series)", amazonLink.SerieDisplayText);
Assert.AreEqual(serieText, amazonLink.SerieInfo.RawText);
Assert.AreEqual("1", amazonLink.SerieInfo.Number);
Assert.AreEqual(19, amazonLink.SerieInfo.Count);
Assert.AreEqual(20, amazonLink.SerieInfo.Count);
}

[TestMethod]
Expand Down
6 changes: 3 additions & 3 deletions Tests/SearcherTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public void TestGetResults()
Assert.AreEqual(@"https://m.media-amazon.com/images/I/91n3NKbV9aL._AC_UY654_QL65_.jpg", linkFarm.ImageLink);
Assert.AreEqual("Farmhand", linkFarm.SerieInfo.Serie);
Assert.AreEqual("Farmhand", linkFarm.SerieInfo.SerieLink.Title);
Assert.IsTrue(Regex.IsMatch(linkFarm.SerieInfo.SerieLink.SerieDisplayText, @"Farmhand \(\d+? book series\)"));
//Assert.IsTrue(Regex.IsMatch(linkFarm.SerieInfo.SerieLink.SerieDisplayText, @"Farmhand \(\d+? book series\)"));
Assert.AreEqual("16", linkFarm.SerieInfo.Number);
//Assert.AreEqual(19, linkFarm.SerieInfo.Count);
Assert.IsTrue(Regex.IsMatch(linkFarm.SerieDisplayText, @"Farmhand \(16 of \d+? book series\)"));
Assert.IsTrue(Regex.IsMatch(linkFarm.SerieDisplayText, @"Farmhand \(book series\)"));

}

Expand All @@ -65,7 +65,7 @@ public void TestGetResultsSerie()
Assert.IsTrue(res.Count > 0);
Assert.AreEqual("B07JJ7S3BR", linkFarm.ASIN);
Assert.AreEqual("Farmhand", linkFarm.Title);
Assert.IsTrue(Regex.IsMatch(linkFarm.SerieDisplayText, @"Farmhand \(\d+? book series\)"));
//Assert.IsTrue(Regex.IsMatch(linkFarm.SerieDisplayText, @"Farmhand \(\d+ book series\)"));
Assert.AreEqual(@"https://www.amazon.com/dp/B07JJ7S3BR", linkFarm.Link);
}
}
Expand Down

0 comments on commit c9e1fe0

Please sign in to comment.