Search in sources :

Example 11 with Repository

use of uk.ivanc.archimvvm.model.Repository in project archi by ivacf.

the class MainViewModelTest method shouldSearchUsernameWithRepos.

@Test
public void shouldSearchUsernameWithRepos() {
    String username = "usernameWithRepos";
    TextView textView = new TextView(application);
    textView.setText(username);
    List<Repository> mockRepos = MockModelFabric.newListOfRepositories(10);
    doReturn(rx.Observable.just(mockRepos)).when(githubService).publicRepositories(username);
    mainViewModel.onSearchAction(textView, EditorInfo.IME_ACTION_SEARCH, null);
    verify(dataListener).onRepositoriesChanged(mockRepos);
    assertEquals(mainViewModel.infoMessageVisibility.get(), View.INVISIBLE);
    assertEquals(mainViewModel.progressVisibility.get(), View.INVISIBLE);
    assertEquals(mainViewModel.recyclerViewVisibility.get(), View.VISIBLE);
}
Also used : Repository(uk.ivanc.archimvvm.model.Repository) TextView(android.widget.TextView) Test(org.junit.Test)

Example 12 with Repository

use of uk.ivanc.archimvvm.model.Repository in project archi by ivacf.

the class ItemRepoViewModelTest method shouldGetDescription.

@Test
public void shouldGetDescription() {
    Repository repository = new Repository();
    repository.description = "This is the description";
    ItemRepoViewModel itemRepoViewModel = new ItemRepoViewModel(application, repository);
    assertEquals(repository.description, itemRepoViewModel.getDescription());
}
Also used : Repository(uk.ivanc.archimvvm.model.Repository) ItemRepoViewModel(uk.ivanc.archimvvm.viewmodel.ItemRepoViewModel) Test(org.junit.Test)

Example 13 with Repository

use of uk.ivanc.archimvvm.model.Repository in project archi by ivacf.

the class ItemRepoViewModelTest method shouldGetForks.

@Test
public void shouldGetForks() {
    Repository repository = new Repository();
    repository.forks = 5;
    String expectedString = application.getString(R.string.text_forks, repository.forks);
    ItemRepoViewModel itemRepoViewModel = new ItemRepoViewModel(application, repository);
    assertEquals(expectedString, itemRepoViewModel.getForks());
}
Also used : Repository(uk.ivanc.archimvvm.model.Repository) ItemRepoViewModel(uk.ivanc.archimvvm.viewmodel.ItemRepoViewModel) Test(org.junit.Test)

Aggregations

Repository (uk.ivanc.archimvvm.model.Repository)13 Test (org.junit.Test)10 ItemRepoViewModel (uk.ivanc.archimvvm.viewmodel.ItemRepoViewModel)7 TextView (android.widget.TextView)3 Context (android.content.Context)1 Intent (android.content.Intent)1 Observable (android.databinding.Observable)1 ActionBar (android.support.v7.app.ActionBar)1 View (android.view.View)1 List (java.util.List)1 Random (java.util.Random)1 HttpException (retrofit2.adapter.rxjava.HttpException)1 Subscriber (rx.Subscriber)1 ArchiApplication (uk.ivanc.archimvvm.ArchiApplication)1 GithubService (uk.ivanc.archimvvm.model.GithubService)1 RepositoryViewModel (uk.ivanc.archimvvm.viewmodel.RepositoryViewModel)1