mvrx-mocking / com.airbnb.mvrx.mocking / MockMavericksViewModelConfigFactory

MockMavericksViewModelConfigFactory

open class MockMavericksViewModelConfigFactory : MavericksViewModelConfigFactory

Parameters

context - The application context. If provided this will be used to register a ViewModelStatePrinter for each ViewModel to enable mock state printing.

Constructors

<init>

MockMavericksViewModelConfigFactory(context: Context?, debugMode: Boolean = true)

Properties

mockBehavior

var mockBehavior: MockBehavior

Determines what sort of mocked state store is created when provideConfig is called. This can be changed via withMockBehavior to affect behavior when creating a new Fragment.

Functions

buildConfig

open fun <S : MavericksState> buildConfig(viewModel: MavericksViewModel<S>, initialState: S): MavericksViewModelConfig<S>

popMockBehaviorOverride

fun popMockBehaviorOverride(): Unit

pushMockBehaviorOverride

fun pushMockBehaviorOverride(mockBehavior: MockBehavior): Unit

Changes the current MockBehavior of all running ViewModels, if they were created when mockBehavior was non null. This forces the mock behavior to this new value.

withMockBehavior

fun <R> withMockBehavior(mockBehavior: MockBehavior = this.mockBehavior, block: () -> R): R

Any view models created within the block will be given a viewmodel store that was created according to the rules of the given mock behavior. The default value may have been set by a wrapping call to withMockBehavior (ie if multiple calls to withMockBehavior are nested the most recent call can change the behavior of the outer call)