package com.github.ferstl.depgraph.dot;

import org.junit.Test;
import static org.junit.Assert.assertEquals;


public class LabelBuilderTest {

  @Test
  public void mixed() {
    String label = new LabelBuilder()
        .bold("bold text")
        .text("intermediate text")
        .italic("italic text")
        .newLine()
        .underline("underlined text")
        .text("intermediate text")
        .font()
        .color("red")
        .size(20)
        .name("Sans")
        .text("special")
        .text("intermediate text")
        .build();

    assertEquals(
        "<<b>bold text</b>"
            + "intermediate text"
            + "<i>italic text</i>"
            + "<br/>"
            + "<u>underlined text</u>"
            + "intermediate text"
            + "<font color=\"red\" face=\"Sans\" point-size=\"20\">special</font>"
            + "intermediate text>",
        label);
  }

  @Test
  public void htmlEscape() {
    String label = new LabelBuilder()
        .text("<foo>")
        .underline("&bar&")
        .build();

    assertEquals("<&lt;foo&gt;<u>&amp;bar&amp;</u>>", label);
  }

  @Test
  public void fontName() {
    String label = new LabelBuilder()
        .font()
        .name("Helvetica")
        .text("text")
        .build();

    assertEquals("<<font face=\"Helvetica\">text</font>>", label);
  }

  @Test
  public void fontSize() {
    String label = new LabelBuilder()
        .font()
        .size(10)
        .text("text")
        .build();

    assertEquals("<<font point-size=\"10\">text</font>>", label);
  }

  @Test(expected = IllegalArgumentException.class)
  public void fontSizeNegative() {
    new LabelBuilder()
        .font()
        .size(-1);
  }

  @Test
  public void fontColor() {
    String label = new LabelBuilder()
        .font()
        .color("red")
        .text("text")
        .build();

    assertEquals("<<font color=\"red\">text</font>>", label);
  }

  @Test
  public void fontAll() {
    String label = new LabelBuilder()
        .font()
        .name("Helvetica")
        .color("green")
        .size(12)
        .text("text")
        .build();

    assertEquals("<<font color=\"green\" face=\"Helvetica\" point-size=\"12\">text</font>>", label);
  }
}

@@ -1103,32 +1103,667 @@
 %22, label);%0A  %7D%0A%0A
+  @Test%0A  public void text() %7B%0A    String label = new LabelBuilder()%0A        .text(%22text%22)%0A        .build();%0A%0A    assertEquals(%22%3Ctext%3E%22, label);%0A  %7D%0A%0A  @Test%0A  public void bold() %7B%0A    String label = new LabelBuilder()%0A        .bold(%22text%22)%0A        .build();%0A%0A    assertEquals(%22%3C%3Cb%3Etext%3C/b%3E%3E%22, label);%0A  %7D%0A%0A  @Test%0A  public void italic() %7B%0A    String label = new LabelBuilder()%0A        .italic(%22text%22)%0A        .build();%0A%0A    assertEquals(%22%3C%3Ci%3Etext%3C/i%3E%3E%22, label);%0A  %7D%0A%0A  @Test%0A  public void underline() %7B%0A    String label = new LabelBuilder()%0A        .underline(%22text%22)%0A        .build();%0A%0A    assertEquals(%22%3C%3Cu%3Etext%3C/u%3E%3E%22, label);%0A  %7D%0A%0A
   @Test%0A  public

Add more tests