it: improve block tests

This commit is contained in:
Bixilon 2022-10-18 19:46:09 +02:00
parent 9d096cb256
commit f8feb47758
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
9 changed files with 48 additions and 15 deletions

View File

@ -17,5 +17,6 @@ import de.bixilon.kutil.cast.CastUtil.unsafeNull
import de.bixilon.minosoft.data.registries.versions.Version
object IT {
var V_1_18_2: Version = unsafeNull()
const val VERSION_NAME = "1.18.2"
var VERSION: Version = unsafeNull()
}

View File

@ -20,11 +20,9 @@ import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfileMan
import de.bixilon.minosoft.data.registries.DefaultRegistries
import de.bixilon.minosoft.data.registries.versions.Versions
import de.bixilon.minosoft.protocol.packets.factory.PacketTypeRegistry
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
import de.bixilon.minosoft.util.logging.Log
import de.bixilon.minosoft.util.logging.LogLevels
import de.bixilon.minosoft.util.logging.LogMessageType
import org.testng.Assert
import org.testng.annotations.BeforeTest
@ -38,7 +36,7 @@ internal object MinosoftSIT {
loadVersionsJson()
loadAssetsProperties()
loadDefaultRegistries()
`load 1_18_2 PixLyzer data`()
loadPixlyzerData()
Log.log(LogMessageType.OTHER, LogLevels.INFO) { "Integration tests setup successfully!" }
}
@ -74,13 +72,17 @@ internal object MinosoftSIT {
DefaultRegistries.load(CountUpAndDownLatch(0))
}
fun `load 1_18_2 PixLyzer data`() {
val version = Versions["1.18.2"]!!
Assert.assertEquals(version.versionId, ProtocolVersions.V_1_18_2)
IT.V_1_18_2 = version
private fun createResourcesProfile(): ResourcesProfile {
ResourcesProfileManager.currentLoadingPath = "dummy"
val profile = ResourcesProfile()
ResourcesProfileManager.currentLoadingPath = null
version.load(profile, CountUpAndDownLatch(0))
return profile
}
fun loadPixlyzerData() {
val version = Versions[IT.VERSION_NAME]!!
IT.VERSION = version
version.load(createResourcesProfile(), CountUpAndDownLatch(0))
}
}

View File

@ -28,7 +28,7 @@ abstract class BlockTest<T : Block> {
fun retrieveBlock(name: ResourceLocation) {
val block = IT.V_1_18_2.registries!!.blockRegistry[name]
val block = IT.VERSION.registries!!.blockRegistry[name]
Assert.assertNotNull(block)
block!!
assertEquals(block.resourceLocation, name)

View File

@ -19,7 +19,7 @@ import org.testng.annotations.Test
internal object CobwebTest : BlockTest<Block>() {
@Test
private fun getOakLeaves() {
private fun getCobweb() {
super.retrieveBlock(MinecraftBlocks.COBWEB)
}

View File

@ -19,7 +19,7 @@ import org.testng.annotations.Test
internal object GlassTest : BlockTest<Block>() {
@Test
private fun getOakLeaves() {
private fun getGlass() {
super.retrieveBlock(MinecraftBlocks.GLASS)
}

View File

@ -0,0 +1,30 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.blocks
import de.bixilon.minosoft.data.registries.blocks.types.SlimeBlock
import org.testng.annotations.Test
internal object SlimeTest : BlockTest<SlimeBlock>() {
@Test
private fun getSlimeBlock() {
super.retrieveBlock(MinecraftBlocks.SLIME_BLOCK)
}
@Test
fun testLightProperties() {
super.testLightProperties(0, true, false, true, booleanArrayOf(true, true, true, true, true, true))
}
}

View File

@ -19,7 +19,7 @@ import org.testng.annotations.Test
internal object StairsTest : BlockTest<Block>() {
@Test
private fun getOakLeaves() {
private fun getOakStairs() {
super.retrieveBlock(MinecraftBlocks.OAK_STAIRS)
}

View File

@ -19,7 +19,7 @@ import org.testng.annotations.Test
internal object StoneTest : BlockTest<Block>() {
@Test
private fun getOakLeaves() {
private fun getStone() {
super.retrieveBlock(MinecraftBlocks.STONE)
}

View File

@ -19,7 +19,7 @@ import org.testng.annotations.Test
internal object TorchTest : BlockTest<Block>() {
@Test
private fun getOakLeaves() {
private fun getTorch() {
super.retrieveBlock(MinecraftBlocks.TORCH)
}