package de.retest.recheck.printer.leaf;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import de.retest.ui.diff.DurationDifference;

class DurationDifferencePrinterTest {

	DurationDifferencePrinter cut;

	@BeforeEach
	void setUp() {
		cut = new DurationDifferencePrinter();
	}

	@Test
	void toString_should_print_difference() {
		final DurationDifference difference = mock( DurationDifference.class );
		when( difference.getExpected() ).thenReturn( 0L );
		when( difference.getActual() ).thenReturn( 1L );

		final String string = cut.toString( difference );

		assertThat( string ).isEqualTo( "0.001 s" );
	}

	@Test
	void toString_should_respect_indent() {
		final DurationDifference difference = mock( DurationDifference.class );
		when( difference.getExpected() ).thenReturn( 0L );
		when( difference.getActual() ).thenReturn( 1L );

		final String string = cut.toString( difference, "____" );

		assertThat( string ).startsWith( "____" );
	}
}

@@ -471,21 +471,31 @@
 _should_
-print
+handle_positive
 _differe
@@ -730,24 +730,24 @@
 ference );%0A%0A
-
 %09%09assertThat
@@ -781,24 +781,368 @@
 1 s%22 );%0A%09%7D%0A%0A
+%09@Test%0A%09void toString_should_handle_negative_difference() %7B%0A%09%09final DurationDifference difference = mock( DurationDifference.class );%0A%09%09when( difference.getExpected() ).thenReturn( 1L );%0A%09%09when( difference.getActual() ).thenReturn( 0L );%0A%0A%09%09final String string = cut.toString( difference );%0A%0A%09%09assertThat( string ).isEqualTo( %22-0.001 s%22 );%0A%09%7D%0A%0A
 %09@Test%0A%09void

Add tests for positive and negative duration differences