aboutsummaryrefslogtreecommitdiff
path: root/src/cz/crcs/ectester/standalone/test/KeyGeneratorTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/cz/crcs/ectester/standalone/test/KeyGeneratorTest.java')
-rw-r--r--src/cz/crcs/ectester/standalone/test/KeyGeneratorTest.java42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/cz/crcs/ectester/standalone/test/KeyGeneratorTest.java b/src/cz/crcs/ectester/standalone/test/KeyGeneratorTest.java
new file mode 100644
index 0000000..9032415
--- /dev/null
+++ b/src/cz/crcs/ectester/standalone/test/KeyGeneratorTest.java
@@ -0,0 +1,42 @@
+package cz.crcs.ectester.standalone.test;
+
+import cz.crcs.ectester.common.test.Result;
+import cz.crcs.ectester.common.test.SimpleTest;
+import cz.crcs.ectester.common.test.TestCallback;
+import cz.crcs.ectester.common.test.TestException;
+
+/**
+ * @author Jan Jancar johny@neuromancer.sk
+ */
+public class KeyGeneratorTest extends SimpleTest<KeyGeneratorTestable> {
+ private KeyGeneratorTest(KeyGeneratorTestable kg, TestCallback<KeyGeneratorTestable> callback) {
+ super(kg, callback);
+ }
+
+ public static KeyGeneratorTest expect(KeyGeneratorTestable kg, Result.ExpectedValue expected) {
+ return new KeyGeneratorTest(kg, new TestCallback<KeyGeneratorTestable>() {
+ @Override
+ public Result apply(KeyGeneratorTestable keyGenerationTestable) {
+ return new Result(Result.Value.fromExpected(expected, keyGenerationTestable.ok(), keyGenerationTestable.error()));
+ }
+ });
+ }
+
+ public static KeyGeneratorTest function(KeyGeneratorTestable ka, TestCallback<KeyGeneratorTestable> callback) {
+ return new KeyGeneratorTest(ka, callback);
+ }
+
+ @Override
+ public String getDescription() {
+ return null;
+ }
+
+ @Override
+ public void run() throws TestException {
+ if (hasRun)
+ return;
+ testable.run();
+ result = callback.apply(testable);
+ hasRun = true;
+ }
+}