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);
  }
}

@@ -1109,11 +1109,1132 @@
 el);%0A  %7D
+%0A%0A  @Test%0A  public void fontName() %7B%0A    String label = new LabelBuilder()%0A        .font()%0A        .name(%22Helvetica%22)%0A        .text(%22text%22)%0A        .build();%0A%0A    assertEquals(%22%3C%3Cfont face=%5C%22Helvetica%5C%22%3Etext%3C/font%3E%3E%22, label);%0A  %7D%0A%0A  @Test%0A  public void fontSize() %7B%0A    String label = new LabelBuilder()%0A        .font()%0A        .size(10)%0A        .text(%22text%22)%0A        .build();%0A%0A    assertEquals(%22%3C%3Cfont point-size=%5C%2210%5C%22%3Etext%3C/font%3E%3E%22, label);%0A  %7D%0A%0A  @Test(expected = IllegalArgumentException.class)%0A  public void fontSizeNegative() %7B%0A    new LabelBuilder()%0A        .font()%0A        .size(-1);%0A  %7D%0A%0A  @Test%0A  public void fontColor() %7B%0A    String label = new LabelBuilder()%0A        .font()%0A        .color(%22red%22)%0A        .text(%22text%22)%0A        .build();%0A%0A    assertEquals(%22%3C%3Cfont color=%5C%22red%5C%22%3Etext%3C/font%3E%3E%22, label);%0A  %7D%0A%0A  @Test%0A  public void fontAll() %7B%0A    String label = new LabelBuilder()%0A        .font()%0A        .name(%22Helvetica%22)%0A        .color(%22green%22)%0A        .size(12)%0A        .text(%22text%22)%0A        .build();%0A%0A    assertEquals(%22%3C%3Cfont color=%5C%22green%5C%22 face=%5C%22Helvetica%5C%22 point-size=%5C%2212%5C%22%3Etext%3C/font%3E%3E%22, label);%0A  %7D
 %0A%7D%0A

Add tests for fonts