mercredi 11 décembre 2019

Mock or create empty GoogleMapMarker

I am working on Unit test for my ViewModel. There is some live data that should update and trigger by a Google Map Marker that updates from Fragment. In my unit test i wanna create simple marker with mock Latitude and longitude so i can check functionality and business of viewModel. But i could not create any instance of marker. It needs some odd class zzt.

    @Test
    fun registerSelectedMarkerFromMap(){

    val marker = com.google.android.gms.maps.model.Marker(???)
    marker.position = LatLng(12.0,12.0)
    viewModel.updateCameraUpdate(viewModel.calculatePointsThatVisible(marker.position))
    viewModel.updateSelectionMarker(marker)

    viewModel.getMarkerChange.observeForTesting {
        Assert.assertEquals(viewModel.getMarkerChange.value!!.position, marker.position)
    }

}

I wonder if i can mock this model i will able to pass this to my viewModel and check its functionality.

Aucun commentaire:

Enregistrer un commentaire