package com.stolets.rxdiffutil;

import com.stolets.rxdiffutil.util.MockitoUtils;

import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

public class DefaultDiffCallbackTest {
    private final DefaultDiffCallback<String, TestModel, TestAdapter<TestModel>> callback = MockitoUtils.getStubbedDefaultDiffCallback();

    @Test
    public void areContentsTheSame_ComparesModelData() {
        // Given the model objects

        // When
        boolean whenSameResult = callback.areContentsTheSame(0, 0);
        boolean whenDifferentResult = callback.areContentsTheSame(1, 1);

        // Then
        assertThat(whenSameResult, is(true));
        assertThat(whenDifferentResult, is(false));
    }

    @Test
    public void areItemsTheSame_ComparesModelIds() {
        // Given the model objects

        // When
        boolean whenDifferentResult = callback.areItemsTheSame(0, 0);
        boolean whenSameResult = callback.areItemsTheSame(1, 1);

        // Then
        assertThat(whenSameResult, is(true));
        assertThat(whenDifferentResult, is(false));
    }

    @Test
    public void testListSizes() {
        assertThat(callback.getOldListSize(), is(2));
        assertThat(callback.getNewListSize(), is(2));
    }
}

@@ -26,16 +26,58 @@
 futil;%0A%0A
+import android.support.v7.util.DiffUtil;%0A%0A
 import c
@@ -140,16 +140,68 @@
 it.Test;
+%0Aimport org.mockito.InOrder;%0A%0Aimport java.util.List;
 %0A%0Aimport
@@ -286,16 +286,99 @@
 hers.is;
+%0Aimport static org.mockito.Mockito.inOrder;%0Aimport static org.mockito.Mockito.mock;
 %0A%0Apublic
@@ -1460,11 +1460,824 @@
 );%0A    %7D
+%0A%0A    @SuppressWarnings(%22unchecked%22)%0A    @Test%0A    public void update_UpdatesAdapterData() %7B%0A        // Given%0A        final DiffUtil.DiffResult mockedDiffResult = mock(DiffUtil.DiffResult.class);%0A        final List%3CTestModel%3E mockedData = mock(List.class);%0A        final TestAdapter%3CTestModel%3E mockedAdapter = mock(TestAdapter.class);%0A        final DefaultDiffCallback%3CString, TestModel, TestAdapter%3CTestModel%3E%3E mockedDefaultDiffCallback = new DefaultDiffCallback%3C%3E(mockedData, mockedData, mockedAdapter);%0A%0A        // When%0A        mockedDefaultDiffCallback.update(mockedDiffResult);%0A%0A        // Then%0A        final InOrder inOrder = inOrder(mockedAdapter, mockedDiffResult);%0A%0A        inOrder.verify(mockedAdapter).update(mockedData);%0A        inOrder.verify(mockedDiffResult).dispatchUpdatesTo(mockedAdapter);%0A    %7D
 %0A%7D%0A

Add update method unit test