Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
DyeColorTest.java
1 package org.bukkit;
2 
3 import static org.junit.Assert.*;
4 import static org.hamcrest.Matchers.*;
5 
6 import java.util.ArrayList;
7 import java.util.List;
8 
10 import org.bukkit.material.Dye;
11 import org.bukkit.material.Wool;
12 import org.junit.Test;
13 import org.junit.runner.RunWith;
14 import org.junit.runners.Parameterized;
15 import org.junit.runners.Parameterized.Parameter;
16 import org.junit.runners.Parameterized.Parameters;
17 
18 @RunWith(Parameterized.class)
19 public class DyeColorTest {
20 
21  @Parameters(name= "{index}: {0}")
22  public static List<Object[]> data() {
23  List<Object[]> list = new ArrayList<Object[]>();
24  for (DyeColor dye : DyeColor.values()) {
25  list.add(new Object[] {dye});
26  }
27  return list;
28  }
29 
30  @Parameter public DyeColor dye;
31 
32  @Test
33  @SuppressWarnings("deprecation")
34  public void getByData() {
35  byte data = dye.getData();
36 
37  DyeColor byData = DyeColor.getByData(data);
38  assertThat(byData, is(dye));
39  }
40 
41  @Test
42  public void getByWoolData() {
43  byte data = dye.getWoolData();
44 
45  DyeColor byData = DyeColor.getByWoolData(data);
46  assertThat(byData, is(dye));
47  }
48 
49  @Test
50  public void getByDyeData() {
51  byte data = dye.getDyeData();
52 
53  DyeColor byData = DyeColor.getByDyeData(data);
54  assertThat(byData, is(dye));
55  }
56 
57  @Test
58  public void getDyeDyeColor() {
59  testColorable(new Dye(Material.INK_SACK, dye.getDyeData()));
60  }
61 
62  @Test
63  public void getWoolDyeColor() {
64  testColorable(new Wool(Material.WOOL, dye.getWoolData()));
65  }
66 
67  private void testColorable(final Colorable colorable) {
68  assertThat(colorable.getColor(), is(this.dye));
69  }
70 }
static DyeColor getByDyeData(final byte data)
Definition: DyeColor.java:193
static DyeColor getByData(final byte data)
Definition: DyeColor.java:161
static DyeColor getByWoolData(final byte data)
Definition: DyeColor.java:175