Updated view model testing.

This commit is contained in:
vsuryakumar
2023-01-27 13:21:20 +05:30
parent a43365268f
commit b8789d59bb
2 changed files with 7472 additions and 36 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,16 +1,18 @@
package com.example.refactoredapp package com.example.refactoredapp
import com.example.refactoredapp.data.Constants import com.example.refactoredapp.data.Constants
import com.example.refactoredapp.data.model.PatientData
import com.example.refactoredapp.presentation.testRight.TestRightViewModel import com.example.refactoredapp.presentation.testRight.TestRightViewModel
import junit.framework.Assert.assertEquals import junit.framework.Assert.assertEquals
import org.junit.Test import org.junit.Test
class TestRightViewModelTest { class TestRightViewModelTest {
private val viewModel = TestRightViewModel() private val viewModel = TestRightViewModel()
private val data = InputData()
@Test @Test
fun testRightViewModel_mapDeviceConstants() { fun testRightViewModel_mapDeviceConstants() {
viewModel.mapDeviceConstants(inputRead) viewModel.mapDeviceConstants(data.inputRead)
assertEquals("0", viewModel.deviceConstant!!.a) assertEquals("0", viewModel.deviceConstant!!.a)
assertEquals("1.69989422e-06", viewModel.deviceConstant!!.b) assertEquals("1.69989422e-06", viewModel.deviceConstant!!.b)
assertEquals("1.60642711e-01", viewModel.deviceConstant!!.c) assertEquals("1.60642711e-01", viewModel.deviceConstant!!.c)
@@ -19,7 +21,7 @@ class TestRightViewModelTest {
@Test @Test
fun testRightViewModel_mapPixelNumberToWavelength() { fun testRightViewModel_mapPixelNumberToWavelength() {
viewModel.mapDeviceConstants(inputRead) viewModel.mapDeviceConstants(data.inputRead)
viewModel.mapPixelNumberToWavelength() viewModel.mapPixelNumberToWavelength()
for (each in viewModel.wavelengthToPixelArray){ for (each in viewModel.wavelengthToPixelArray){
@@ -32,43 +34,50 @@ class TestRightViewModelTest {
} }
@Test @Test
fun testRightViewModel_mapIntensityValues() { fun testRightViewModel_calculateResults() {
viewModel.mapIntensityValues(fullStringPrint, true) viewModel.mapDeviceConstants(data.inputRead)
viewModel.mapPixelNumberToWavelength()
viewModel.mapIntensityValues(data.printForReference, true)
viewModel.mapIntensityValues(data.printForSample, false)
viewModel.patientDetails = PatientData("Surya", 2, "Male", null)
viewModel.calculateResults()
for (each in viewModel.intensityReferenceArray){
System.out.print(each[0])
System.out.print(" -> ")
System.out.println(each[1])
}
assertEquals(23, viewModel.intensityReferenceArray.size)
} }
val inputRead = "0,1.69989422e-06,1.60642711e-01, 3.85754470e+02,0,0,1,0, FFF-EEEE-PPP-WW-YY-NNNN\nОК [01]"
val fullStringPrint = "Buf 3672: 0\n" + @Test
"Buf 3673 : 0\n" + fun testRightViewModel_calculateDataForCSV() {
"Buf 3674 : 0\n" +
"Buf 3675 : 0\n" + viewModel.mapDeviceConstants(data.inputRead)
"Buf 3676: 0\n" + viewModel.mapPixelNumberToWavelength()
"Buf 3677: 0\n" + viewModel.mapIntensityValues(data.printForReference, true)
"Buf 3678: 0\n" + viewModel.mapIntensityValues(data.printForSample, false)
"Buf 3679 : 0\n" + // viewModel.patientDetails = PatientData("Surya", 2, "Male", null)
"Buf 3680: 0\n" + // viewModel.calculateResults()
"Buf 3681 : 0\n" + viewModel.calculateDataForCSV()
"Buf 3682 : 0\n" +
"Buf 3683 : 0\n" + for (each in viewModel.wavelengthToAbsorbance){
"Buf 3684 : 0\n" + println(each[0].toString() + " -> " + each[1])
"Buf 3685 : 0\n" + }
"Buf 3686: 0\n" + }
"Buf 3687: 0\n" +
"Buf 3688 : 0\n" + // @Test
"Buf 3689 : 0\n" + // fun testRightViewModel_mapIntensityValues() {
"Buf 3690 : 0\n" + //
"Buf 3691 : 0\n" + // viewModel.mapIntensityValues(data.fullStringPrint, true)
"Buf 3692 : 0\n" + //
"Buf 3693 : 0\n" + // for (each in viewModel.intensityReferenceArray){
"Buf 3694 : 0\n" + // System.out.print(each[0])
"ок [0]" // System.out.print(" -> ")
// System.out.println(each[1])
// }
//
// assertEquals(23, viewModel.intensityReferenceArray.size)
// }
} }