-
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Isanz
committed
May 7, 2024
1 parent
98ab4f3
commit 1855264
Showing
4 changed files
with
74 additions
and
34 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
24 changes: 0 additions & 24 deletions
24
app/src/androidTest/java/com/isanz/inmomarket/ExampleInstrumentedTest.kt
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
app/src/androidTest/java/com/isanz/inmomarket/InmomarketInstrumentedTest.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.isanz.inmomarket | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import com.isanz.inmomarket.ui.add.AddViewModel | ||
import com.isanz.inmomarket.ui.chat.ChatViewModel | ||
import com.isanz.inmomarket.ui.home.HomeViewModel | ||
import com.isanz.inmomarket.ui.profile.ProfileViewModel | ||
import com.isanz.inmomarket.ui.search.SearchViewModel | ||
import com.isanz.inmomarket.ui.settings.SettingsViewModel | ||
import com.isanz.inmomarket.utils.Constants | ||
import com.isanz.inmomarket.utils.entities.Message | ||
import com.isanz.inmomarket.utils.entities.Property | ||
import org.junit.Assert.* | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import java.lang.reflect.Method | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class InmomarketInstrumentedTest { | ||
@Test | ||
fun viewModelsNotNull() { | ||
val chatViewModel = ChatViewModel() | ||
assertNotNull(chatViewModel) | ||
val homeViewModel = HomeViewModel() | ||
assertNotNull(homeViewModel) | ||
val addViewModel = AddViewModel() | ||
assertNotNull(addViewModel) | ||
val searchViewModel = SearchViewModel() | ||
assertNotNull(searchViewModel) | ||
val profileViewModel = ProfileViewModel() | ||
assertNotNull(profileViewModel) | ||
val settingsViewModel = SettingsViewModel() | ||
assertNotNull(settingsViewModel) | ||
} | ||
|
||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.isanz.inmomarket", appContext.packageName) | ||
} | ||
|
||
@Test | ||
fun chatMessageHasRightFormat() { | ||
val chatViewModel = ChatViewModel() | ||
val createMesssageMetoth: Method = ChatViewModel::class.java.getDeclaredMethod("createMessage", String::class.java, String::class.java) | ||
createMesssageMetoth.isAccessible = true | ||
val message : Message = createMesssageMetoth.invoke(chatViewModel, "Hello", "123") as Message | ||
assertEquals("Hello", message.message ) | ||
assertEquals("123", message.senderId) | ||
} | ||
} |
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