Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
FixedMetadataValueTest.java
1 package org.bukkit.metadata;
2 
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertSame;
5 
6 import org.bukkit.plugin.Plugin;
8 import org.junit.Test;
9 
10 public class FixedMetadataValueTest {
11  private Plugin plugin = new TestPlugin("X");
12  private FixedMetadataValue subject;
13 
14  @Test
15  public void testBasic() {
16  subject = new FixedMetadataValue(plugin, new Integer(50));
17  assertSame(plugin, subject.getOwningPlugin());
18  assertEquals(new Integer(50), subject.value());
19  }
20 
21  @Test
22  public void testNumberTypes() {
23  subject = new FixedMetadataValue(plugin, new Integer(5));
24  assertEquals(new Integer(5), subject.value());
25  assertEquals(5, subject.asInt());
26  assertEquals(true, subject.asBoolean());
27  assertEquals(5, subject.asByte());
28  assertEquals(5.0, subject.asFloat(), 0.1e-8);
29  assertEquals(5.0D, subject.asDouble(), 0.1e-8D);
30  assertEquals(5L, subject.asLong());
31  assertEquals(5, subject.asShort());
32  assertEquals("5", subject.asString());
33  }
34 
35  @Test
36  public void testInvalidateDoesNothing() {
37  Object o = new Object();
38  subject = new FixedMetadataValue(plugin, o);
39  subject.invalidate();
40  assertSame(o, subject.value());
41  }
42 }