-
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
1 parent
1d13b04
commit 9fffc7a
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/androidTest/java/com/infomaniak/lib/core/ExtensionsTest.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,41 @@ | ||
package com.infomaniak.lib.core | ||
|
||
import android.content.Context | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.infomaniak.lib.core.utils.humanReadableBinaryBytesCount | ||
import org.junit.Assert | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.mockito.Mock | ||
import org.mockito.Mockito.mock | ||
import org.mockito.Mockito.`when` | ||
import org.mockito.MockitoAnnotations | ||
|
||
/** | ||
* Extensions file test | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExtensionsTest { | ||
|
||
@Mock | ||
lateinit var mockContext: Context | ||
|
||
@Before | ||
fun setup() { | ||
MockitoAnnotations.initMocks(this) | ||
mockContext = mock(Context::class.java) | ||
`when`(mockContext.applicationContext).thenReturn(mockContext) | ||
} | ||
|
||
@Test | ||
fun humanReadableBinaryBytesCount() { | ||
// Arrange (already in setup) | ||
|
||
// Act | ||
val result = mockContext.humanReadableBinaryBytesCount(1_500L) | ||
|
||
// Assert | ||
Assert.assertEquals(result, "1.5 KB") | ||
} | ||
} |
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