|
| 1 | +package com.codedifferently.lesson9.natayaprice; |
| 2 | + |
| 3 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 4 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 5 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 6 | + |
| 7 | +import org.junit.jupiter.api.Test; |
| 8 | + |
| 9 | +public class BookTest { |
| 10 | + |
| 11 | + /** Tests the constructor of the {@link Book} class. */ |
| 12 | + @Test |
| 13 | + public void testConstructor() { |
| 14 | + Book book = new Book("Title", 1234567890, "Author", 200, false); |
| 15 | + assertEquals("Title", book.getTitles()); |
| 16 | + assertEquals(1234567890, book.getISBN()); |
| 17 | + assertEquals("Author", book.getAuthors()); |
| 18 | + assertEquals(200, book.getTotalPages()); |
| 19 | + assertFalse(book.getCheckedOut()); |
| 20 | + } |
| 21 | + |
| 22 | + /** Tests the {@code getTitles()} method of the {@link Book} class. */ |
| 23 | + @Test |
| 24 | + public void testGetTitle() { |
| 25 | + Book book = new Book("Children of Blood and Bone", 972, "Tomi Adeyemi", 544, false); |
| 26 | + assertEquals("Children of Blood and Bone", book.getTitles()); |
| 27 | + } |
| 28 | + |
| 29 | + /** Tests the {@code getISBN()} method of the {@link Book} class. */ |
| 30 | + @Test |
| 31 | + public void testGetISBN() { |
| 32 | + Book book = |
| 33 | + new Book("The Sisters Grimm:The Fairy-Tale Detectives", 571, "Michael Buckley", 176, true); |
| 34 | + assertEquals(571, book.getISBN()); |
| 35 | + } |
| 36 | + |
| 37 | + /** Tests the {@code getAuthors()} method of the {@link Book} class. */ |
| 38 | + @Test |
| 39 | + public void testGetAuthors() { |
| 40 | + Book book = new Book("A Light in the Attic", 739, "Shel Silverstein", 176, true); |
| 41 | + assertEquals("Shel Silverstein", book.getAuthors()); |
| 42 | + } |
| 43 | + |
| 44 | + /** Tests the {@code getTotalPages()} method of the {@link Book} class. */ |
| 45 | + @Test |
| 46 | + public void testGetTotalPages() { |
| 47 | + Book book = |
| 48 | + new Book("Junie B. Jones and the Mushy Gushy Valentine", 408, "Barbara Park", 80, true); |
| 49 | + assertEquals(80, book.getTotalPages()); |
| 50 | + } |
| 51 | + |
| 52 | + /** Tests the {@code getCheckedOut()} method of the {@link Book} class. */ |
| 53 | + @Test |
| 54 | + public void testGetCheckedOut() { |
| 55 | + Book book = |
| 56 | + new Book("Thirst: Human Urges, Fatal Consequences", 060, "Michael Farquhar", 384, false); |
| 57 | + assertFalse(book.getCheckedOut()); |
| 58 | + } |
| 59 | + |
| 60 | + @Test |
| 61 | + public void testIsCheckedOut() { |
| 62 | + Book book = new Book("Women Who Run with the Wolves", 874, "Clarissa Pinkola Estés", 560, true); |
| 63 | + assertTrue(book.getCheckedOut()); |
| 64 | + } |
| 65 | + |
| 66 | + /** Tests the {@code getCheckedIn()} method of the {@link Book} class. */ |
| 67 | + @Test |
| 68 | + public void testGetCheckedIn() { |
| 69 | + Book book = new Book("Beloved", 416, "Toni Morrison", 324, false); |
| 70 | + assertFalse(book.getCheckedOut()); |
| 71 | + } |
| 72 | +} |
0 commit comments