Browse Source

More testing

Sam Jaffe 5 years ago
parent
commit
4f27f86ea5

+ 33 - 0
src/test/java/org/leumasjaffe/recipe/model/CollatedDurationTest.java

@@ -0,0 +1,33 @@
+package org.leumasjaffe.recipe.model;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.leumasjaffe.recipe.model.Duration.Display.*;
+
+import org.junit.jupiter.api.Test;
+
+class CollatedDurationTest {
+
+	@Test
+	void testAddZeroIsSelf() {
+		final CollatedDuration collate = new CollatedDuration(
+				new Duration(SECONDS, 0, 10), new Duration(SECONDS, 0, 20),
+				new Duration(SECONDS, 0, 60));
+		
+		assertEquals(collate, collate.plus(CollatedDuration.ZERO));
+		assertEquals(collate, CollatedDuration.ZERO.plus(collate));
+	}
+	
+	@Test
+	void testAddsElementsSeparately() {
+		final CollatedDuration collate = new CollatedDuration(
+				new Duration(SECONDS, 0, 10), new Duration(SECONDS, 0, 20),
+				new Duration(SECONDS, 0, 60));
+
+		final CollatedDuration expected = new CollatedDuration(
+				new Duration(SECONDS, 0, 20), new Duration(SECONDS, 0, 40),
+				new Duration(SECONDS, 0, 120));
+
+		assertEquals(expected, collate.plus(collate));
+	}
+
+}

+ 8 - 0
src/test/java/org/leumasjaffe/recipe/model/DurationTest.java

@@ -14,6 +14,14 @@ import org.junit.jupiter.params.provider.EnumSource;
 import org.junit.jupiter.params.provider.ValueSource;
 
 class DurationTest {
+	
+	@Test
+	void testAddZeroIsSelf() {
+		final Duration dur = new Duration(SECONDS, 0, 10);
+		
+		assertEquals(dur, dur.plus(Duration.ZERO));
+		assertEquals(dur, Duration.ZERO.plus(dur));
+	}
 
 	@Test
 	void testPlusConvertsToLowestUnit() {