public void GenCartTest2() { StreamWriter sw = new StreamWriter(@"TestFiles\Outs\Cart2.html"); List <Book> books = new List <Book>(); for (int i = 0; i < 8; i++) { Book book = new Book() { Id = (i * i * i + 150) / (i + 1), Title = $"Title Book{i * 2 + 1}", Author = $"Author{i + 42 * 57 - 8}", Price = i * i + 15 * i, }; books.Add(book); } ModelStore store = new ModelStore(); store.books = books; Customer cust = new Customer(); IList <Book> booklist = store.GetBooks(); List <ShoppingCartItem> Items = new List <ShoppingCartItem>(); for (int i = 0; i < booklist.Count; i++) { ShoppingCartItem item = new ShoppingCartItem() { BookId = booklist[i].Id, Count = i * 150 + 10, }; Items.Add(item); } View.GenCart(sw, "Kachna", Items, store); sw.Close(); bool b = Utils.FileDiff(@"TestFiles\Outs\Cart2.html", @"TestFiles\Cart2.txt"); Assert.IsTrue(b); }
public static void Render(int custId, ModelStore modelStore) { ViewHeader.Render(custId, modelStore); Console.WriteLine(" Our books for you:"); Console.WriteLine(" <table>"); var books = modelStore.GetBooks(); for (int i = 0; i < books.Count; i++) { var book = books[i]; // start new row if (i % 3 == 0) { // end last row if (i != 0) { Console.WriteLine(" </tr>"); } Console.WriteLine(" <tr>"); } Console.WriteLine(" <td style=\"padding: 10px;\">"); Console.WriteLine(" <a href=\"/Books/Detail/"+ book.Id.ToString() + "\">" + book.Title + "</a><br />"); Console.WriteLine(" Author: "+ book.Author + "<br />"); Console.WriteLine(" Price: "+ book.Price.ToString() + " EUR <<a href=\"/ShoppingCart/Add/" + book.Id.ToString() + "\">Buy</a>>"); Console.WriteLine(" </td>"); } if (books.Count > 0) { // end last row Console.WriteLine(" </tr>"); } Console.WriteLine(" </table>"); Console.WriteLine("</body>"); Console.WriteLine("</html>"); }