Browse Source

implemented set capitals in configure menu

feature-vault
fdai6352 3 years ago
parent
commit
6d43a35632
  1. 14
      src/main/java/Vault.java
  2. 19
      src/test/java/VaultTest.java

14
src/main/java/Vault.java

@ -39,11 +39,15 @@ public class Vault implements VaultInterface {
if (input.equals("e")) {
config = false;
}else if (input.equals("l")) {
} else if (input.equals("l")) {
println("Set PW length:");
String inputPw = scan.nextLine();
setPWLength(inputPw);
}else if (!input.equals("l")|!input.equals("e")|!input.equals("h")) {
} else if (input.equals("h")) {
println("Should your PW have capitals? Type in yes or no.");
String inputC = scan.nextLine();
setPWLength(inputC);
} else if (!input.equals("l")|!input.equals("e")|!input.equals("h")) {
println("Please enter valid key.");
}
@ -83,11 +87,7 @@ public class Vault implements VaultInterface {
}
public void setCapital() {
println("Should you PW have capitals? Type in yes or no.");
Scanner scan = new Scanner(inputS);
String input = scan.nextLine();
public void setCapital(String input) {
if(input.equals("yes")){
haveCapitals = true;

19
src/test/java/VaultTest.java

@ -110,21 +110,26 @@ public class VaultTest {
}
@Test
void setCapital() {
vlt.inputS = new ByteArrayInputStream("yes\n".getBytes(StandardCharsets.UTF_8));
void openSetCapitalsMenuItem() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
vlt.inputS = new ByteArrayInputStream("h\nyes".getBytes(StandardCharsets.UTF_8));
vlt.outputS = outputStream;
vlt.setCapital();
vlt.configure();
assertTrue(vlt.haveCapitals = true);
}
@Test
void setCapitals() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
vlt.outputS = outputStream;
vlt.setCapital("yes");
assertTrue(outputStream.toString().startsWith("Should"));
assertTrue(vlt.haveCapitals = true);
assertTrue(outputStream.toString().contains("contain"));
vlt.inputS = new ByteArrayInputStream("no\n".getBytes(StandardCharsets.UTF_8));
vlt.outputS = outputStream;
vlt.setCapital();
vlt.setCapital("no");
assertTrue(outputStream.toString().startsWith("Should"));
assertFalse(vlt.haveCapitals = false);
assertTrue(outputStream.toString().contains("don´t"));
}

Loading…
Cancel
Save