This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class NameValidatorTest { | |
| private val nameValidator = NameValidator() | |
| @Test | |
| fun 'isValid should return false when name is empty'() { | |
| val name = "" | |
| assertEquals(false, nameValidator.isValid(name)) | |
| } | |
| @Test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private const val MIN_NAME_LENGTH = 3 | |
| class NameValidator { | |
| fun isValid(name: String): Boolean { | |
| return when { | |
| name.isEmpty() -> false | |
| name.length < MIN_NAME_LENGTH -> false | |
| else -> true | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class FileUtils { | |
| fun getDirectoryFilesListSize(context: Context, fileDirectory: String): Int { | |
| val directory = File(context.filesDir, fileDirectory) | |
| val fileList = directory.listFiles().orEmpty() | |
| return fileList.size | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| fun shouldReturnNumberOfFilesInsideADirectory() { | |
| //Given | |
| val bananaDirectory = "bananas" | |
| createFileAtInternalDirectory(context, bananaDirectory, "prata") | |
| createFileAtInternalDirectory(context, bananaDirectory, "d'agua") | |
| createFileAtInternalDirectory(context, bananaDirectory, "nanica") | |
| //When | |
| val directoryFileListSize = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| fun shouldEnableButtonWhenValidMessageIsTyped() { | |
| onView(withId(R.id.messageField)).perform(typeText("you do not talk about Fight Club")) | |
| onView(withId(R.id.sendButton)).check(matches(isEnabled())) | |
| } | |
| @Test | |
| fun shouldNotEnableButtonWhenInvalidMessageIsTyped() { | |
| onView(withId(R.id.messageField)).perform(typeText("Hey, let me tell you about the Fight Club")) | |
| onView(withId(R.id.sendButton)).check(matches(not(isEnabled()))) |