Ejemplo n.º 1
0
    public void RegionCreateExistingChunkTest()
    {
        IRegion region = new Region(_worldMapMock.Object, 0, 0, _serviceProvider);
        IChunk  chunk  = region.AddChunk(0, 0);

        Assert.Throws <InvalidOperationException>(() => region.AddChunk(0, 0));
    }
Ejemplo n.º 2
0
    public void RegionGetBlockTest(int x, int y, int z)
    {
        var region = new Region(_worldMapMock.Object, 0, 0, _serviceProvider);

        region.AddChunk(0, 0);
        region.AddChunk(1, 0);
        region.AddChunk(0, 1);
        region.AddChunk(1, 1);

        IBlock block = region.GetBlock(x, y, z);

        Assert.NotNull(block);
        Assert.IsType <Block>(block);
        Assert.Equal(BlockType.Air, block.Type);
        Assert.True(block.IsAir);
    }
Ejemplo n.º 3
0
    public void RegionCheckIfContainsChunkTest()
    {
        var region = new Region(_worldMapMock.Object, 0, 0, _serviceProvider);

        region.AddChunk(0, 0);

        Assert.True(region.ContainsChunk(0, 0));
    }
Ejemplo n.º 4
0
    public void RegionGetExistingChunkTest()
    {
        var    region = new Region(_worldMapMock.Object, 0, 0, _serviceProvider);
        IChunk chunk  = region.AddChunk(0, 0);

        Assert.NotNull(chunk);
        Assert.Same(chunk, region.GetChunk(0, 0));
    }
Ejemplo n.º 5
0
    public void RegionCreateChunkTest()
    {
        IRegion region = new Region(_worldMapMock.Object, 0, 0, _serviceProvider);
        IChunk  chunk  = region.AddChunk(0, 0);

        Assert.NotNull(chunk);
        Assert.IsType <Chunk>(chunk);
        Assert.Equal(0, chunk.X);
        Assert.Equal(0, chunk.Z);
        Assert.NotEmpty(region.Chunks.Where(x => x is not null));
    }
Ejemplo n.º 6
0
    public void RegionSetBlockAtChunkTest(int x, int y, int z, BlockType blockType)
    {
        var region = new Region(_worldMapMock.Object, 0, 0, _serviceProvider);

        region.AddChunk(0, 0);
        region.AddChunk(1, 0);
        region.AddChunk(0, 1);
        region.AddChunk(1, 1);

        IBlock placedBlock = region.SetBlock(blockType, x, y, z);
        IBlock block       = region.GetBlock(x, y, z);

        Assert.NotNull(placedBlock);
        Assert.NotNull(block);
        Assert.Equal(placedBlock, block);
        Assert.IsType <Block>(placedBlock);
        Assert.IsType <Block>(block);
        Assert.Equal(blockType, block.Type);
        Assert.False(block.IsAir);
    }