summaryrefslogtreecommitdiff
path: root/src/test/java/com/p4square/grow/model/SliderQuestionTest.java
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2016-04-09 14:22:20 -0700
committerJesse Morgan <jesse@jesterpm.net>2016-04-09 15:48:01 -0700
commit3102d8bce3426d9cf41aeaf201c360d342677770 (patch)
tree38c4f1e8828f9af9c4b77a173bee0d312b321698 /src/test/java/com/p4square/grow/model/SliderQuestionTest.java
parentbbf907e51dfcf157bdee24dead1d531122aa25db (diff)
Switching from Ivy+Ant to Maven.
Diffstat (limited to 'src/test/java/com/p4square/grow/model/SliderQuestionTest.java')
-rw-r--r--src/test/java/com/p4square/grow/model/SliderQuestionTest.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/test/java/com/p4square/grow/model/SliderQuestionTest.java b/src/test/java/com/p4square/grow/model/SliderQuestionTest.java
new file mode 100644
index 0000000..b5c4e83
--- /dev/null
+++ b/src/test/java/com/p4square/grow/model/SliderQuestionTest.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2013 Jesse Morgan
+ */
+
+package com.p4square.grow.model;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests for SliderQuestion.
+ *
+ * @author Jesse Morgan <jesse@jesterpm.net>
+ */
+public class SliderQuestionTest {
+ private static final double DELTA = 1e-4;
+
+ public static void main(String... args) {
+ org.junit.runner.JUnitCore.main(SliderQuestionTest.class.getName());
+ }
+
+ private Question mQuestion;
+
+ @Before
+ public void setUp() {
+ mQuestion = new SliderQuestion();
+
+ // Add some "answers" for the scoring engine.
+ mQuestion.getAnswers().put("1", new Answer());
+ mQuestion.getAnswers().put("2", new Answer());
+ mQuestion.getAnswers().put("3", new Answer());
+ mQuestion.getAnswers().put("4", new Answer());
+ }
+
+ /**
+ * The ScoringEngines are tested extensively independently, so simply
+ * verify that we get the expected results for our input.
+ */
+ @Test
+ public void testScoreAnswer() {
+ Score score = new Score();
+ RecordedAnswer answer = new RecordedAnswer();
+
+ answer.setAnswerId("0.66666");
+ assertTrue(mQuestion.scoreAnswer(score, answer));
+ assertEquals(3, score.sum, DELTA);
+ assertEquals(1, score.count);
+
+ answer.setAnswerId("1");
+ assertTrue(mQuestion.scoreAnswer(score, answer));
+ assertEquals(7, score.sum, DELTA);
+ assertEquals(2, score.count);
+ }
+
+ /**
+ * Verify the correct type string is returned.
+ */
+ @Test
+ public void testType() {
+ assertEquals("slider", mQuestion.getType().toString());
+ }
+}