Keypad { public void keyUp(Key key) { pressedKeys[key.ordinal()] = false; byte keyUpValue = getKeypadUpValue(key); byte newKeypadValue = (byte) (mmu.readByte(KEYPAD_ADDRESS) & 0xFF | keyUpValue); mmu.writeByte(KEYPAD_ADDRESS, newKeypadValue); updateColumn(); } Keypad(MMU mmu); void keyUp(Key key); void keyDown(Key key);  }
@Test public void shouldEnableAllTheBitsRelatedToTheKeypad() { Keypad keypad = givenAKeypad(); pressAllKeysDown(keypad); keypad.keyUp(Key.DOWN); keypad.keyUp(Key.RIGHT); assertEquals(8, mmu.readByte(KEYPAD_ADDRESS) & 0x8); assertEquals(1, mmu.readByte(KEYPAD_ADDRESS) & 0x1); }