CollatedDurationTest.java 957 B

123456789101112131415161718192021222324252627282930313233
  1. package org.leumasjaffe.recipe.model;
  2. import static org.junit.jupiter.api.Assertions.*;
  3. import static org.leumasjaffe.recipe.model.Duration.Display.*;
  4. import org.junit.jupiter.api.Test;
  5. class CollatedDurationTest {
  6. @Test
  7. void testAddZeroIsSelf() {
  8. final CollatedDuration collate = new CollatedDuration(
  9. new Duration(SECONDS, 0, 10), new Duration(SECONDS, 0, 20),
  10. new Duration(SECONDS, 0, 60));
  11. assertEquals(collate, collate.plus(CollatedDuration.ZERO));
  12. assertEquals(collate, CollatedDuration.ZERO.plus(collate));
  13. }
  14. @Test
  15. void testAddsElementsSeparately() {
  16. final CollatedDuration collate = new CollatedDuration(
  17. new Duration(SECONDS, 0, 10), new Duration(SECONDS, 0, 20),
  18. new Duration(SECONDS, 0, 60));
  19. final CollatedDuration expected = new CollatedDuration(
  20. new Duration(SECONDS, 0, 20), new Duration(SECONDS, 0, 40),
  21. new Duration(SECONDS, 0, 120));
  22. assertEquals(expected, collate.plus(collate));
  23. }
  24. }