public void ThenTheBookListShouldExactlyContainBooks(string titleList) { var books = actionResult.Model<List<Book>>(); var titles = titleList.Split(',').Select(t => t.Trim().Trim('\'')); foreach (var title in titles) CustomAssert.Any(books, b => b.Title == title); Assert.AreEqual(titles.Count(), books.Count, "The list contains other books too"); }
public void ThenTheHomePageShowsBooks(Table table) { var books = actionResult.Model <List <Book> >(); var titles = table.Rows.Select(r => r["Title"]); foreach (var title in titles) { CustomAssert.Any(books, b => b.Title == title); } Assert.AreEqual(titles.Count(), books.Count, "The list contains other books too"); }
public void ThenTheBookListShouldExactlyContainBooks(string titleList) { var books = actionResult.Model; var titles = titleList.Split(',').Select(t => t.Trim().Trim('\'')); foreach (var title in titles) { CustomAssert.Any(books, b => b.Title == title); } Assert.AreEqual(titles.Count(), books.Count, "The list contains other books too"); foreach (var book in books) { // you can make assertions for the HTML result as well: StringAssert.Contains("Catalog/Details/" + book.Id, actionResult.ResponseText); } }
public void ThenTheBookListShouldExactlyContainBooks(string titleList) { var titles = titleList.Split(',').Select(t => t.Trim().Trim('\'')); var itemCount = selenium.GetXpathCount("//table/tbody/tr"); var books = new List <Book>(); const int headerCount = 1; for (int i = headerCount + 1; i <= itemCount; i++) { string title = selenium.GetText("//table/tbody/tr[" + i + "]/td[@class='title']"); string author = selenium.GetText("//table/tbody/tr[" + i + "]/td[@class='author']"); books.Add(new Book { Title = title, Author = author }); } foreach (var title in titles) { CustomAssert.Any(books, b => b.Title == title); } Assert.AreEqual(titles.Count(), books.Count, "The list contains other books too"); }
public void ThenTheHomePageShowsBook(string title) { var books = actionResult.Model <List <Book> >(); CustomAssert.Any(books, b => b.Title == title); }