@@ -0,0 +1,3237 @@
+package com.blundell.quicksand;%0A%0Aimport android.view.ViewPropertyAnimator;%0A%0Aimport com.blundell.quicksand.viscosity.Viscosity;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.mockito.Mock;%0Aimport org.mockito.MockitoAnnotations;%0A%0Aimport static org.fest.assertions.api.Assertions.assertThat;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.when;%0A%0Apublic class DurationCalculatorTest %7B%0A%0A    @Mock%0A    AccessibleTransition mockTransition;%0A    @Mock%0A    ViewPropertyAnimator mockViewPropertyAnimator;%0A    @Mock%0A    Viscosity mockViscosity;%0A    private DurationCalculator calc;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        MockitoAnnotations.initMocks(this);%0A        calc = new DurationCalculator();%0A    %7D%0A%0A    @Test%0A    public void givenTransitionHasDurationZeroWhenDurationCalculatedThenCalculatedDurationIsZero() throws Exception %7B%0A        when(mockTransition.getDuration()).thenReturn(0L);%0A%0A        long duration = calc.calculateNewDuration(mockTransition, 0, mockViscosity);%0A%0A        assertThat(duration).isEqualTo(0L);%0A    %7D%0A%0A    @Test%0A    public void givenViewPropertyAnimatorHasDurationZeroWhenDurationCalculatedThenCalculatedDurationIsZero() throws Exception %7B%0A        when(mockViewPropertyAnimator.getDuration()).thenReturn(0L);%0A%0A        long duration = calc.calculateNewDuration(mockViewPropertyAnimator, 0, mockViscosity);%0A%0A        assertThat(duration).isEqualTo(0L);%0A    %7D%0A%0A    @Test%0A    public void givenTransitionViewedForFirstTimeWhenDurationCalculatedThenCalculatedDurationIsCurrentDuration() throws Exception %7B%0A        long currentDuration = 50L;%0A        when(mockTransition.getDuration()).thenReturn(currentDuration);%0A%0A        long duration = calc.calculateNewDuration(mockTransition, 0, mockViscosity);%0A%0A        assertThat(duration).isEqualTo(currentDuration);%0A    %7D%0A%0A    @Test%0A    public void givenViewPropertyAnimatorViewedForFirstTimeWhenDurationCalculatedThenCalculatedDurationIsCurrentDuration() throws Exception %7B%0A        long currentDuration = 50L;%0A        when(mockViewPropertyAnimator.getDuration()).thenReturn(currentDuration);%0A%0A        long duration = calc.calculateNewDuration(mockViewPropertyAnimator, 0, mockViscosity);%0A%0A        assertThat(duration).isEqualTo(currentDuration);%0A    %7D%0A%0A    @Test%0A    public void givenATransitionWhenDurationCalculatedThenCalculatedDurationIsDelegatedToTheViscosity() throws Exception %7B%0A        int timesTransitionViewed = 1;%0A        long currentDuration = 50L;%0A        when(mockTransition.getDuration()).thenReturn(currentDuration);%0A%0A        calc.calculateNewDuration(mockTransition, timesTransitionViewed, mockViscosity);%0A%0A        verify(mockViscosity).calculateDuration(currentDuration, timesTransitionViewed);%0A    %7D%0A%0A    @Test%0A    public void givenAViewPropertyAnimatorWhenDurationCalculatedThenCalculatedDurationIsDelegatedToTheViscosity() throws Exception %7B%0A        int timesTransitionViewed = 1;%0A        long currentDuration = 50L;%0A        when(mockViewPropertyAnimator.getDuration()).thenReturn(currentDuration);%0A%0A        calc.calculateNewDuration(mockViewPropertyAnimator, timesTransitionViewed, mockViscosity);%0A%0A        verify(mockViscosity).calculateDuration(currentDuration, timesTransitionViewed);%0A    %7D%0A%7D%0A

test the duration calculator