Search in sources :

Example 1 with ItemRepoViewModel

use of uk.ivanc.archimvvm.viewmodel.ItemRepoViewModel in project archi by ivacf.

the class ItemRepoViewModelTest method shouldGetStars.

@Test
public void shouldGetStars() {
    Repository repository = new Repository();
    repository.stars = 10;
    String expectedString = application.getString(R.string.text_stars, repository.stars);
    ItemRepoViewModel itemRepoViewModel = new ItemRepoViewModel(application, repository);
    assertEquals(expectedString, itemRepoViewModel.getStars());
}
Also used : Repository(uk.ivanc.archimvvm.model.Repository) ItemRepoViewModel(uk.ivanc.archimvvm.viewmodel.ItemRepoViewModel) Test(org.junit.Test)

Example 2 with ItemRepoViewModel

use of uk.ivanc.archimvvm.viewmodel.ItemRepoViewModel in project archi by ivacf.

the class ItemRepoViewModelTest method shouldGetWatchers.

@Test
public void shouldGetWatchers() {
    Repository repository = new Repository();
    repository.watchers = 7;
    String expectedString = application.getString(R.string.text_watchers, repository.watchers);
    ItemRepoViewModel itemRepoViewModel = new ItemRepoViewModel(application, repository);
    assertEquals(expectedString, itemRepoViewModel.getWatchers());
}
Also used : Repository(uk.ivanc.archimvvm.model.Repository) ItemRepoViewModel(uk.ivanc.archimvvm.viewmodel.ItemRepoViewModel) Test(org.junit.Test)

Example 3 with ItemRepoViewModel

use of uk.ivanc.archimvvm.viewmodel.ItemRepoViewModel in project archi by ivacf.

the class ItemRepoViewModelTest method shouldNotifyPropertyChangeWhenSetRepository.

@Test
public void shouldNotifyPropertyChangeWhenSetRepository() {
    Repository repository = new Repository();
    ItemRepoViewModel itemRepoViewModel = new ItemRepoViewModel(application, repository);
    Observable.OnPropertyChangedCallback mockCallback = mock(Observable.OnPropertyChangedCallback.class);
    itemRepoViewModel.addOnPropertyChangedCallback(mockCallback);
    itemRepoViewModel.setRepository(repository);
    verify(mockCallback).onPropertyChanged(any(Observable.class), anyInt());
}
Also used : Repository(uk.ivanc.archimvvm.model.Repository) ItemRepoViewModel(uk.ivanc.archimvvm.viewmodel.ItemRepoViewModel) Observable(android.databinding.Observable) Test(org.junit.Test)

Example 4 with ItemRepoViewModel

use of uk.ivanc.archimvvm.viewmodel.ItemRepoViewModel in project archi by ivacf.

the class ItemRepoViewModelTest method shouldStartActivityOnItemClick.

@Test
public void shouldStartActivityOnItemClick() {
    Repository repository = new Repository();
    Context mockContext = mock(Context.class);
    ItemRepoViewModel itemRepoViewModel = new ItemRepoViewModel(mockContext, repository);
    itemRepoViewModel.onItemClick(new View(application));
    verify(mockContext).startActivity(any(Intent.class));
}
Also used : Context(android.content.Context) Repository(uk.ivanc.archimvvm.model.Repository) ItemRepoViewModel(uk.ivanc.archimvvm.viewmodel.ItemRepoViewModel) Intent(android.content.Intent) View(android.view.View) Test(org.junit.Test)

Example 5 with ItemRepoViewModel

use of uk.ivanc.archimvvm.viewmodel.ItemRepoViewModel in project archi by ivacf.

the class ItemRepoViewModelTest method shouldGetName.

@Test
public void shouldGetName() {
    Repository repository = new Repository();
    repository.name = "ivan";
    ItemRepoViewModel itemRepoViewModel = new ItemRepoViewModel(application, repository);
    assertEquals(repository.name, itemRepoViewModel.getName());
}
Also used : Repository(uk.ivanc.archimvvm.model.Repository) ItemRepoViewModel(uk.ivanc.archimvvm.viewmodel.ItemRepoViewModel) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 Repository (uk.ivanc.archimvvm.model.Repository)7 ItemRepoViewModel (uk.ivanc.archimvvm.viewmodel.ItemRepoViewModel)7 Context (android.content.Context)1 Intent (android.content.Intent)1 Observable (android.databinding.Observable)1 View (android.view.View)1