-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement - Unit Test for Product Feature (#1057)
* Enhancement - Unit Test for Product Feature - Close #1056 * 🤖 Updates screenshots
- Loading branch information
Showing
76 changed files
with
2,323 additions
and
112 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
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
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
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
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
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
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
55 changes: 55 additions & 0 deletions
55
core/domain/src/test/java/com/niyaj/domain/cartorder/ValidateOrderAddressNameUseCaseTest.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,55 @@ | ||
/* | ||
* Copyright 2024 Sk Niyaj Ali | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package com.niyaj.domain.cartorder | ||
|
||
import com.niyaj.common.tags.CartOrderTestTags.ADDRESS_NAME_LENGTH_ERROR | ||
import com.niyaj.common.tags.CartOrderTestTags.CART_ORDER_NAME_EMPTY_ERROR | ||
import com.niyaj.testing.util.MainDispatcherRule | ||
import org.junit.Rule | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertFalse | ||
import kotlin.test.assertNull | ||
|
||
class ValidateOrderAddressNameUseCaseTest { | ||
@get:Rule | ||
val dispatcherRule = MainDispatcherRule() | ||
val useCase = ValidateOrderAddressNameUseCase() | ||
|
||
@Test | ||
fun `given empty address name when invoke then return error`() { | ||
val result = useCase("") | ||
assert(result.successful.not()) | ||
assertEquals(CART_ORDER_NAME_EMPTY_ERROR, result.errorMessage) | ||
} | ||
|
||
@Test | ||
fun `given address name length less than 6 digit return error`() { | ||
val result = useCase("Test") | ||
|
||
assertFalse(result.successful) | ||
assertEquals(ADDRESS_NAME_LENGTH_ERROR, result.errorMessage) | ||
} | ||
|
||
@Test | ||
fun `given valid address name return success`() { | ||
val result = useCase("Test Address") | ||
assert(result.successful) | ||
assertNull(result.errorMessage) | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
.../domain/src/test/java/com/niyaj/domain/cartorder/ValidateOrderCustomerPhoneUseCaseTest.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,68 @@ | ||
/* | ||
* Copyright 2024 Sk Niyaj Ali | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package com.niyaj.domain.cartorder | ||
|
||
import com.niyaj.common.tags.CartOrderTestTags.CART_ORDER_PHONE_EMPTY_ERROR | ||
import com.niyaj.common.tags.CartOrderTestTags.CUSTOMER_PHONE_LENGTH_ERROR | ||
import com.niyaj.common.tags.CartOrderTestTags.CUSTOMER_PHONE_LETTER_ERROR | ||
import com.niyaj.testing.util.MainDispatcherRule | ||
import org.junit.Rule | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertNull | ||
|
||
class ValidateOrderCustomerPhoneUseCaseTest { | ||
@get:Rule | ||
val dispatcherRule = MainDispatcherRule() | ||
val useCase = ValidateOrderCustomerPhoneUseCase() | ||
|
||
@Test | ||
fun `validate with empty phone return error`() { | ||
val result = useCase("") | ||
assert(result.successful.not()) | ||
assertEquals(CART_ORDER_PHONE_EMPTY_ERROR, result.errorMessage) | ||
} | ||
|
||
@Test | ||
fun `validate phone no with less than 10 digit return error`() { | ||
val result = useCase("123") | ||
assert(result.successful.not()) | ||
assertEquals(CUSTOMER_PHONE_LENGTH_ERROR, result.errorMessage) | ||
} | ||
|
||
@Test | ||
fun `validate phone no with greater than 10 digit return error`() { | ||
val result = useCase("1239078563421") | ||
assert(result.successful.not()) | ||
assertEquals(CUSTOMER_PHONE_LENGTH_ERROR, result.errorMessage) | ||
} | ||
|
||
@Test | ||
fun `validate phone no with with letter return error`() { | ||
val result = useCase("123456789P") | ||
assert(result.successful.not()) | ||
assertEquals(CUSTOMER_PHONE_LETTER_ERROR, result.errorMessage) | ||
} | ||
|
||
@Test | ||
fun `validate with valid phone return success`() { | ||
val result = useCase("1234567890") | ||
assert(result.successful) | ||
assertNull(result.errorMessage) | ||
} | ||
} |
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
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
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
Oops, something went wrong.