forked from huunam1108/AndroidSetup
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
402f409
commit 22872b6
Showing
6 changed files
with
180 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,5 @@ buildSrc/build/ | |
gkc_* | ||
|
||
# captured images or li | ||
captures/ | ||
captures/ | ||
.framgia-ci-reports/ |
This file contains 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
This file contains 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
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/namnh/androidsetup/logic/MainLogic.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.namnh.androidsetup.logic | ||
|
||
class MainLogic { | ||
fun add(a: Int, b: Int) = a + b | ||
fun greet(name: String = "World"): String { | ||
return "Hello, $name!" | ||
} | ||
|
||
fun hasDuplicatedNumber(list: List<Int>, checkNum: Int): Boolean { | ||
val count = list.count { i -> i == checkNum } | ||
return count > 1 | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
app/src/test/java/com/namnh/androidsetup/logic/MainLogicTest.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.namnh.androidsetup.logic | ||
|
||
import org.junit.Assert.* | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.JUnit4 | ||
|
||
@RunWith(JUnit4::class) | ||
class MainLogicTest { | ||
private lateinit var mainLogic: MainLogic | ||
@Before | ||
fun setup() { | ||
mainLogic = MainLogic() | ||
} | ||
|
||
@Test | ||
fun `hello world`() { | ||
assertEquals("Hello, World!", mainLogic.greet()) | ||
} | ||
|
||
@Test | ||
fun `hello NamNH`() { | ||
assertEquals("Hello, NamNH!", mainLogic.greet("NamNH")) | ||
} | ||
|
||
@Test | ||
fun `add positive`() { | ||
assertEquals(2, mainLogic.add(1, 1)) | ||
assertEquals(4, mainLogic.add(1, 3)) | ||
} | ||
|
||
@Test | ||
fun `add negative`() { | ||
assertEquals(2, mainLogic.add(-1, 3)) | ||
assertEquals(4, mainLogic.add(-1, 5)) | ||
} | ||
|
||
@Test | ||
fun `add positive and negative`() { | ||
assertEquals(-1, mainLogic.add(-3, 2)) | ||
assertEquals(2, mainLogic.add(-3, 5)) | ||
} | ||
|
||
@Test | ||
fun `has duplicated number`() { | ||
assertTrue(mainLogic.hasDuplicatedNumber(listOf(1, 2, 3, 4, 2), 2)) | ||
assertTrue(mainLogic.hasDuplicatedNumber(listOf(1, 4, 3, 4, 2), 4)) | ||
} | ||
|
||
@Test | ||
fun `has no duplicated number`() { | ||
assertFalse(mainLogic.hasDuplicatedNumber(listOf(1, 2, 3, 4), 1)) | ||
assertFalse(mainLogic.hasDuplicatedNumber(listOf(1, 2, 3, 4), 2)) | ||
assertFalse(mainLogic.hasDuplicatedNumber(listOf(1, 2, 3, 4), 0)) | ||
assertFalse(mainLogic.hasDuplicatedNumber(listOf(), 0)) | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
project_type: android | ||
build: | ||
configurations: | ||
image: framgiaciteam/android:latest | ||
|
||
test: | ||
download_dependencies: | ||
ignore: false | ||
command: ./gradlew androidDependencies | ||
run_unit_test: | ||
ignore: false | ||
command: ./gradlew testDebugUnitTestCoverage | ||
check_style: | ||
ignore: false | ||
command: ./gradlew ktlintCheck | ||
check_lint: | ||
ignore: false | ||
command: ./gradlew detekt | ||
|
||
cache: | ||
gradle: | ||
folder: ~/.gradle | ||
file: app/build.gradle.kts | ||
|