package io.rudefox.cold; import com.bjdweck.test.CliTestFixture; import org.junit.jupiter.api.Test; import java.io.UnsupportedEncodingException; import static org.junit.jupiter.api.Assertions.assertEquals; class mnemonic_command_tests extends CliTestFixture { @Test void with_arguments_interactive_dice_should_generate_mnemonic_sentence() throws UnsupportedEncodingException { withArgs("mnemonic --interactive --dice6-entropy --bits 128"); expectedOutput("Input 50 dice rolls [1-6]: "); provideInput("234322343242422344161254151\r\n"); expectedOutput("Input 23 more dice rolls [1-6]: "); provideInput("33116265515343114314456\r\n"); expectedOutput("mountain tilt wing silk rude fox almost volume wine media verify card" + EOL); doMain(); verifyOutput(); } @Test void with_no_arguments_should_output_mnemonic() throws UnsupportedEncodingException { withArgs("mnemonic"); doMain(); assertEquals(24, getOutput().split(" ").length); } @Test void with_arguments_non_interactive_dice_bits_should_generate_mnemonic_sentence() throws UnsupportedEncodingException { withArgs("mnemonic --dice6-entropy --events 23432234324242234416125415133116265515343114314456 --bits 128"); expectedOutput("mountain tilt wing silk rude fox almost volume wine media verify card" + EOL); doMain(); verifyOutput(); } @Test void with_arguments_without_interactive_dice_should_generate_mnemonic_sentence() throws UnsupportedEncodingException { withArgs("mnemonic --dice6-entropy --events 2343223432424223441612541513311626551534311431445623432234324242234416125415133116265515343114314456"); expectedOutput("first welcome social broccoli nasty rather weird uncle spirit horn update pencil help rescue " + "grape enough fork wave eight fuel ribbon pony clean couple" + EOL); doMain(); verifyOutput(); } private void doMain() { setInput(); RudefoxCold.main(getArgs()); } }