use of org.terasology.context.internal.MockContext in project Terasology by MovingBlocks.
the class TreeTests method setup.
@Before
public void setup() {
ContextImpl context = new ContextImpl();
CoreRegistry.setContext(context);
// Needed only as long as #1536 is unresolved
context.put(Config.class, new Config(new MockContext()));
blockManager = Mockito.mock(BlockManager.class);
Block air = blockManager.getBlock(BlockManager.AIR_ID);
biomeManager = Mockito.mock(BiomeManager.class);
Mockito.when(blockManager.getBlock(Matchers.<BlockUri>any())).thenReturn(air);
Mockito.when(blockManager.getBlock(Matchers.<String>any())).thenReturn(air);
context.put(BlockManager.class, blockManager);
}
use of org.terasology.context.internal.MockContext in project Terasology by MovingBlocks.
the class InputConfig method reset.
public void reset() {
Config defaultConfig = new Config(new MockContext());
defaultConfig.loadDefaults();
InputConfig defaultInputConfig = defaultConfig.getInput();
setMouseSensitivity(defaultInputConfig.mouseSensitivity);
setMouseYAxisInverted(defaultInputConfig.mouseYAxisInverted);
}
use of org.terasology.context.internal.MockContext in project Terasology by MovingBlocks.
the class ChunkMathTest method testRegionPositions.
@Test
public void testRegionPositions() {
CoreRegistry.setContext(new ContextImpl());
CoreRegistry.put(Config.class, new Config(new MockContext()));
assertEquals(1, ChunkMath.calcChunkPos(Region3i.createFromMinMax(new Vector3i(0, 0, 0), new Vector3i(0, 0, 0))).length);
assertEquals(1, ChunkMath.calcChunkPos(Region3i.createFromMinMax(new Vector3i(0, 0, 0), new Vector3i(31, 63, 31))).length);
assertEquals(2, ChunkMath.calcChunkPos(Region3i.createFromMinMax(new Vector3i(0, 0, 0), new Vector3i(32, 63, 31))).length);
assertEquals(4, ChunkMath.calcChunkPos(Region3i.createFromMinMax(new Vector3i(0, 0, 0), new Vector3i(32, 63, 32))).length);
assertEquals(8, ChunkMath.calcChunkPos(Region3i.createFromMinMax(new Vector3i(0, 0, 0), new Vector3i(32, 64, 32))).length);
assertEquals(12, ChunkMath.calcChunkPos(Region3i.createFromMinMax(new Vector3i(-1, 0, 0), new Vector3i(32, 64, 32))).length);
Vector3i[] chunks = ChunkMath.calcChunkPos(Region3i.createFromMinMax(new Vector3i(0, 0, 0), new Vector3i(32, 63, 31)));
assertEquals(new Vector3i(0, 0, 0), chunks[0]);
assertEquals(new Vector3i(1, 0, 0), chunks[1]);
}
use of org.terasology.context.internal.MockContext in project Terasology by MovingBlocks.
the class IntMathTest method setUpClass.
@BeforeClass
public static void setUpClass() throws Exception {
Config config = new Config(new MockContext());
CoreRegistry.setContext(new ContextImpl());
CoreRegistry.put(Config.class, config);
}
Aggregations