forked from pierront/mylibrary-template
✅ Reussite du test d'ajout de copie dans les stock'
This commit is contained in:
@@ -21,4 +21,7 @@ public class Book {
|
||||
private String description ;
|
||||
private String language;
|
||||
|
||||
public void addStock(Integer copyToAdd){
|
||||
this.stock += copyToAdd;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package fr.iut_fbleau.but3.dev62.mylibrary.book.entity;
|
||||
import fr.iut_fbleau.but3.dev62.mylibrary.book.BookDTO;
|
||||
import fr.iut_fbleau.but3.dev62.mylibrary.book.converter.BookConverter;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.LocalDate;
|
||||
@@ -51,4 +52,37 @@ public class BookTest {
|
||||
assertEquals(description, book.getDescription());
|
||||
assertEquals(language, book.getLanguage());
|
||||
}
|
||||
|
||||
@Nested
|
||||
@DisplayName("Loyalty Points Tests")
|
||||
class StockTests {
|
||||
|
||||
@Test
|
||||
@DisplayName("addCopy should correctly increment stocks")
|
||||
void testAddCopy() {
|
||||
Book book =Book.builder()
|
||||
.stock(5)
|
||||
.build();
|
||||
Integer copyToAdd = 5;
|
||||
Integer copyExpected = 10;
|
||||
|
||||
book.addStock(copyToAdd);
|
||||
|
||||
assertEquals(copyExpected, book.getStock());
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("addCopy should correctly increment zero points correctly")
|
||||
void testAddZeroToCopy() {
|
||||
Book book =Book.builder()
|
||||
.stock(5)
|
||||
.build();
|
||||
Integer copyToAdd = 0;
|
||||
Integer copyExpected = 5;
|
||||
|
||||
book.addStock(copyToAdd);
|
||||
|
||||
assertEquals(copyExpected, book.getStock());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user