Seperated MockWorld tests

This commit is contained in:
Eric Stokes 2011-10-15 08:20:29 -06:00
parent d1f51acb1c
commit edb999578a

View File

@ -2,36 +2,47 @@ package com.onarandombox.MultiverseCore.test;
import junit.framework.Assert; import junit.framework.Assert;
import org.bukkit.World; import org.bukkit.World;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.*;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class) @RunWith(PowerMockRunner.class)
public class TestMockWorld { public class TestMockWorld {
private World mockWorld; private World mockWorld;
private World mockNetherWorld; private World mockNetherWorld;
@Test
public void testWorldInit() { @Before
public void setUp() throws Exception {
// Initialize a fake world and world_nether. // Initialize a fake world and world_nether.
this.mockWorld = PowerMockito.mock(World.class); this.mockWorld = mock(World.class);
when(this.mockWorld.getName()).thenReturn("world"); when(this.mockWorld.getName()).thenReturn("world");
when(this.mockWorld.getEnvironment()).thenReturn(World.Environment.NORMAL); when(this.mockWorld.getEnvironment()).thenReturn(World.Environment.NORMAL);
this.mockNetherWorld = PowerMockito.mock(World.class); this.mockNetherWorld = mock(World.class);
when(this.mockNetherWorld.getName()).thenReturn("world_nether"); when(this.mockNetherWorld.getName()).thenReturn("world_nether");
when(this.mockNetherWorld.getEnvironment()).thenReturn(World.Environment.NETHER); when(this.mockNetherWorld.getEnvironment()).thenReturn(World.Environment.NETHER);
}
@Test
public void testWorldInit() {
Assert.assertNotNull(this.mockWorld);
Assert.assertNotNull(this.mockNetherWorld);
}
@Test
public void testWorldNames() {
// Test the mock world objects // Test the mock world objects
Assert.assertEquals(this.mockWorld.getName(), "world"); Assert.assertEquals(this.mockWorld.getName(), "world");
Assert.assertEquals(this.mockNetherWorld.getName(), "world_nether"); Assert.assertEquals(this.mockNetherWorld.getName(), "world_nether");
verify(this.mockWorld).getName(); verify(this.mockWorld).getName();
verify(this.mockNetherWorld).getName(); verify(this.mockNetherWorld).getName();
}
@Test
public void testWorldEnvironments() {
// Test the environments // Test the environments
Assert.assertEquals(this.mockWorld.getEnvironment(), World.Environment.NORMAL); Assert.assertEquals(this.mockWorld.getEnvironment(), World.Environment.NORMAL);
Assert.assertEquals(this.mockNetherWorld.getEnvironment(), World.Environment.NETHER); Assert.assertEquals(this.mockNetherWorld.getEnvironment(), World.Environment.NETHER);