Sha256: 9a0e51e70a468839eae93323ff571559f8365d73d66f7faf57ba0ea2298a9c85

Contents?: true

Size: 1.86 KB

Versions: 232

Compression:

Stored size: 1.86 KB

Contents

import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import static org.junit.Assert.*;

/**
 * Step 3: Generate random key if key isn't specified. Check key is right format
 */
public class SimpleCipherStepThreeTest {
    @Rule
    public ExpectedException expectedException = ExpectedException.none();

    @Ignore("Remove to run test")
    @Test
    public void cipherKeyIsMadeOfLetters() {
        assertTrue(new Cipher().getKey().matches("[a-z]+"));
    }

    @Ignore("Remove to run test")
    @Test
    public void defaultCipherKeyIs100Characters() {
        assertEquals(100, new Cipher().getKey().length());
    }

    @Ignore("Remove to run test")
    @Test
    public void cipherKeysAreRandomlyGenerated() {
        String newKey = new Cipher().getKey();
        assertFalse("Cipher constructor without argument should generate a random key. No two calls to the" +
                " constructor should generate the same key. Two calls to the constructor " +
                "both returned key: " + newKey, newKey.equals(new Cipher().getKey()));
    }

    @Ignore("Remove to run test")
    @Test
    public void cipherThrowsWithAllCapsKey() {
        expectedException.expect(IllegalArgumentException.class);
        new Cipher("ABCDEF");
    }

    @Ignore("Remove to run test")
    @Test
    public void cipherThrowsWithAnyCapsKey() {
        expectedException.expect(IllegalArgumentException.class);
        new Cipher("abcdEFg");
    }

    @Ignore("Remove to run test")
    @Test
    public void cipherThrowsWithNumericKey() {
        expectedException.expect(IllegalArgumentException.class);
        new Cipher("12345");
    }

    @Ignore("Remove to run test")
    @Test
    public void cipherThrowsWithAnyNumericKey() {
        expectedException.expect(IllegalArgumentException.class);
        new Cipher("abcd345ef");
    }
}

Version data entries

232 entries across 232 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.179 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.178 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.177 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.176 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.175 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.174 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.173 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.172 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.171 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.170 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.169 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.167 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.166 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.165 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.164 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.163 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.162 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.161 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java
trackler-2.2.1.160 tracks/java/exercises/simple-cipher/src/test/java/SimpleCipherStepThreeTest.java