-
public final class MockBehaviorDifferent types of mock setups that can be provided.
When a mocked view model is created, "existing" view model expectations are ignored, and the viewmodel is created from mocked state instead of throwing an exception.
However, it is up to the caller to make sure that a ViewModel of the expected type doesn't already exist in the view model store, otherwise the framework will use that one instead of allowing us to create a new mocked one, so make sure to clear the store of any previously created viewmodels first.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumMockBehavior.InitialStateMockingDescribes how a custom mocked state is applied to initialize a new ViewModel.
public enumMockBehavior.StateStoreBehavior
-
Field Summary
Fields Modifier and Type Field Description private final MockBehavior.InitialStateMockinginitialStateMockingprivate final MavericksBlockExecutionsblockExecutionsprivate final MockBehavior.StateStoreBehaviorstateStoreBehaviorprivate final BooleansubscribeViewToStateUpdates
-
Constructor Summary
Constructors Constructor Description MockBehavior(MockBehavior.InitialStateMocking initialStateMocking, MavericksBlockExecutions blockExecutions, MockBehavior.StateStoreBehavior stateStoreBehavior, Boolean subscribeViewToStateUpdates)
-
Method Summary
Modifier and Type Method Description final MockBehavior.InitialStateMockinggetInitialStateMocking()final MavericksBlockExecutionsgetBlockExecutions()final MockBehavior.StateStoreBehaviorgetStateStoreBehavior()final BooleangetSubscribeViewToStateUpdates()If true, when a view registers a ViewModel via a delegate the view will be subscribed to changes to the state view MavericksView.postInvalidate. -
-
Constructor Detail
-
MockBehavior
MockBehavior(MockBehavior.InitialStateMocking initialStateMocking, MavericksBlockExecutions blockExecutions, MockBehavior.StateStoreBehavior stateStoreBehavior, Boolean subscribeViewToStateUpdates)
-
-
Method Detail
-
getInitialStateMocking
final MockBehavior.InitialStateMocking getInitialStateMocking()
-
getBlockExecutions
final MavericksBlockExecutions getBlockExecutions()
-
getStateStoreBehavior
final MockBehavior.StateStoreBehavior getStateStoreBehavior()
-
getSubscribeViewToStateUpdates
final Boolean getSubscribeViewToStateUpdates()
If true, when a view registers a ViewModel via a delegate the view will be subscribed to changes to the state view MavericksView.postInvalidate. This is the normal behavior of MvRx. This can be set to false so that a Fragment is not updated for state changes during tests.
-
-
-
-