Skip to content
Browse files

more tests

  • Loading branch information...
1 parent e0efafb commit 0d38e7eb4687282ba9adcf899e95ff9dc0f2593f @pholser pholser committed with Nov 5, 2010
View
19 ...junit/parameters/internal/extractors/ExtractingADateValueFromASourceOfRandomnessTest.java
@@ -0,0 +1,19 @@
+package com.pholser.junit.parameters.internal.extractors;
+
+import java.util.Date;
+
+import com.pholser.junit.parameters.random.SourceOfRandomness;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+public class ExtractingADateValueFromASourceOfRandomnessTest {
+ @Test
+ public void interaction() {
+ SourceOfRandomness random = mock(SourceOfRandomness.class);
+ when(random.nextLong()).thenReturn(0L);
+
+ assertEquals(new Date(0L), new DateExtractor().randomValue(random));
+ }
+}
View
17 ...nit/parameters/internal/extractors/ExtractingADoubleValueFromASourceOfRandomnessTest.java
@@ -0,0 +1,17 @@
+package com.pholser.junit.parameters.internal.extractors;
+
+import com.pholser.junit.parameters.random.SourceOfRandomness;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+public class ExtractingADoubleValueFromASourceOfRandomnessTest {
+ @Test
+ public void interaction() {
+ SourceOfRandomness random = mock(SourceOfRandomness.class);
+ when(random.nextDouble()).thenReturn(1.2D);
+
+ assertEquals(Double.valueOf(1.2D), new DoubleExtractor().randomValue(random));
+ }
+}
View
17 ...unit/parameters/internal/extractors/ExtractingAFloatValueFromASourceOfRandomnessTest.java
@@ -0,0 +1,17 @@
+package com.pholser.junit.parameters.internal.extractors;
+
+import com.pholser.junit.parameters.random.SourceOfRandomness;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+public class ExtractingAFloatValueFromASourceOfRandomnessTest {
+ @Test
+ public void interaction() {
+ SourceOfRandomness random = mock(SourceOfRandomness.class);
+ when(random.nextFloat()).thenReturn(3.14F);
+
+ assertEquals(Float.valueOf(3.14F), new FloatExtractor().randomValue(random));
+ }
+}
View
17 ...junit/parameters/internal/extractors/ExtractingALongValueFromASourceOfRandomnessTest.java
@@ -0,0 +1,17 @@
+package com.pholser.junit.parameters.internal.extractors;
+
+import com.pholser.junit.parameters.random.SourceOfRandomness;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+public class ExtractingALongValueFromASourceOfRandomnessTest {
+ @Test
+ public void interaction() {
+ SourceOfRandomness random = mock(SourceOfRandomness.class);
+ when(random.nextLong()).thenReturn(-2L);
+
+ assertEquals(Long.valueOf(-2L), new LongExtractor().randomValue(random));
+ }
+}
View
17 ...unit/parameters/internal/extractors/ExtractingAShortValueFromASourceOfRandomnessTest.java
@@ -0,0 +1,17 @@
+package com.pholser.junit.parameters.internal.extractors;
+
+import com.pholser.junit.parameters.random.SourceOfRandomness;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+public class ExtractingAShortValueFromASourceOfRandomnessTest {
+ @Test
+ public void interaction() {
+ SourceOfRandomness random = mock(SourceOfRandomness.class);
+ when(random.nextInt()).thenReturn(3);
+
+ assertEquals(Short.valueOf("3"), new ShortExtractor().randomValue(random));
+ }
+}
View
17 ...nit/parameters/internal/extractors/ExtractingAStringValueFromASourceOfRandomnessTest.java
@@ -0,0 +1,17 @@
+package com.pholser.junit.parameters.internal.extractors;
+
+import com.pholser.junit.parameters.random.SourceOfRandomness;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+public class ExtractingAStringValueFromASourceOfRandomnessTest {
+ @Test
+ public void interaction() throws Exception {
+ SourceOfRandomness random = mock(SourceOfRandomness.class);
+ when(random.nextBytes(16)).thenReturn("0123456789ABCDEF".getBytes("US-ASCII"));
+
+ assertEquals("0123456789ABCDEF", new StringExtractor().randomValue(random));
+ }
+}
View
17 ...t/parameters/internal/extractors/ExtractingAnIntegerValueFromASourceOfRandomnessTest.java
@@ -0,0 +1,17 @@
+package com.pholser.junit.parameters.internal.extractors;
+
+import com.pholser.junit.parameters.random.SourceOfRandomness;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+public class ExtractingAnIntegerValueFromASourceOfRandomnessTest {
+ @Test
+ public void interaction() {
+ SourceOfRandomness random = mock(SourceOfRandomness.class);
+ when(random.nextInt()).thenReturn(-1);
+
+ assertEquals(Integer.valueOf(-1), new IntegerExtractor().randomValue(random));
+ }
+}

0 comments on commit 0d38e7e

Please sign in to comment.
Something went wrong with that request. Please try again.