package nl.hsac.fitnesse.fixture.slim;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class CompareFixtureTest {
    private final CompareFixture fixture = new CompareFixture();

    @Test
    public void testShowDiff() {
        assertEquals("Same string", "<div>Hello</div>", fixture.differenceBetweenAnd("Hello", "Hello"));
        assertEquals("Different string 2nd longer",
                "<div><span>Hello</span><ins class=\"collapse_rim\">&nbsp;sir</ins></div>",
                fixture.differenceBetweenAnd("Hello", "Hello sir"));
        assertEquals("Different string 2nd shorter",
                "<div><span>Hello</span><del class=\"collapse_rim\">&nbsp;sir</del></div>",
                fixture.differenceBetweenAnd("Hello sir", "Hello"));
        assertEquals("Different string insert",
                "<div><span>Hello </span><ins class=\"collapse_rim\">dear&nbsp;</ins><span>sir</span></div>",
                fixture.differenceBetweenAnd("Hello sir", "Hello dear sir"));
        assertEquals("Different string delete",
                "<div><span>Hello </span><del class=\"collapse_rim\">dear&nbsp;</del><span>sir</span></div>",
                fixture.differenceBetweenAnd("Hello dear sir", "Hello sir"));
        assertEquals("Different string replace",
                "<div><span>Hello </span><del class=\"collapse_rim\">dear</del><ins class=\"collapse_rim\">stupid</ins><span> sir</span></div>",
                fixture.differenceBetweenAnd("Hello dear sir", "Hello stupid sir"));
        assertEquals("Different string extra spaces",
                "<div><span>Hello </span><ins class=\"collapse_rim\">&nbsp;</ins><span>sir</span></div>",
                fixture.differenceBetweenAnd("Hello sir", "Hello  sir"));
        assertEquals("Different string extra spaces",
                "<div><span>Hello </span><ins class=\"collapse_rim\">&nbsp;  &nbsp;</ins><span>sir</span></div>",
                fixture.differenceBetweenAnd("Hello sir", "Hello     sir"));

        assertEquals("Both null", null, fixture.differenceBetweenAnd(null, null));
        assertEquals("One null", "<div><ins class=\"collapse_rim\">Hello</ins></div>", fixture.differenceBetweenAnd(null, "Hello"));
        assertEquals("Two null", "<div><del class=\"collapse_rim\">Bye</del></div>", fixture.differenceBetweenAnd("Bye", null));
    }
}

@@ -2008,16 +2008,73 @@
 sir%22));%0A
+    %7D%0A%0A    @Test%0A    public void testShowDiffWithNull() %7B
 %0A       
@@ -2416,11 +2416,419 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testShowDiffWithHtmlChars() %7B%0A        assertEquals(%22Same string%22, %22%3Cdiv%3E1 &lt; 3%3C/div%3E%22, fixture.differenceBetweenAnd(%221 %3C 3%22, %221 %3C 3%22));%0A        assertEquals(%22Different strings%22,%0A                %22%3Cdiv%3E%3Cspan%3EHello %3C/span%3E%3Cdel class=%5C%22collapse_rim%5C%22%3E&gt;%3C/del%3E%3Cins class=%5C%22collapse_rim%5C%22%3E&lt;%3C/ins%3E%3C/div%3E%22,%0A                fixture.differenceBetweenAnd(%22Hello %3E%22, %22Hello %3C%22));%0A    %7D
 %0A%7D%0A

Improve test