diff --git a/Server/build.gradle b/Server/build.gradle index 4fd38499f..12c015ce9 100644 --- a/Server/build.gradle +++ b/Server/build.gradle @@ -24,6 +24,11 @@ dependencies { implementation 'org.jetbrains.kotlin:kotlin-reflect:1.5.20' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2' implementation group: 'com.moandjiezana.toml', name: 'toml4j', version: '0.7.2' + + //Unit Tests + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0' + implementation files( "libs/PrimitiveExtensions-1.0.jar", "libs/ConstLib-1.4.jar", @@ -37,6 +42,10 @@ dependencies { ) } +test { + useJUnitPlatform() +} + /*sourceSets { main.java.srcDirs = ['src/main/java'] main.kotlin.srcDirs = ['src/main/kotlin'] diff --git a/Server/src/test/kotlin/APITests.kt b/Server/src/test/kotlin/APITests.kt new file mode 100644 index 000000000..1792ff0d3 --- /dev/null +++ b/Server/src/test/kotlin/APITests.kt @@ -0,0 +1,50 @@ +import api.IfaceSettingsBuilder +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test + +object APITests { + @Test fun testIfaceSettings(){ + var builder = IfaceSettingsBuilder() + val testOptions = builder.enableOptions(0..9).build() + Assertions.assertEquals(2046, testOptions, "Testing option flags") + + builder = IfaceSettingsBuilder() + val testSlotSwitch = builder.enableSlotSwitch().build() + Assertions.assertEquals(2097152, testSlotSwitch, "Testing slot switch flag") + + builder = IfaceSettingsBuilder() + val testNullSlot = builder.enableNullSlotSwitch().build() + Assertions.assertEquals(8388608, testNullSlot, "Testing null slotswitch flag") + + builder = IfaceSettingsBuilder() + val testUseWithFlags = builder.setUseOnSettings(true, true, true, true, true, true).build() + Assertions.assertEquals(129024, testUseWithFlags, "Testing usewith flags") + + builder = IfaceSettingsBuilder() + val testIfaceDepth = builder.setInterfaceEventsDepth(2).build() + Assertions.assertEquals(2 shl 18, testIfaceDepth and 1835008, "Testing events depth") + + builder = IfaceSettingsBuilder() + val testUseOption = builder.enableUseOption().build() + Assertions.assertEquals(1 shl 17, testUseOption, "Testing use option") + + builder = IfaceSettingsBuilder() + val testUseOnSelf = builder.enableUseOnSelf().build() + Assertions.assertEquals(1 shl 22, testUseOnSelf, "Testing use on self flag") + + builder = IfaceSettingsBuilder() + val testAllOptions = builder + .enableAllOptions() + .enableExamine() + .enableNullSlotSwitch() + .enableSlotSwitch() + .enableUseOnSelf() + .enableUseOption() + .setInterfaceEventsDepth(2) + .setUseOnSettings(true, true, true, true, true, true) + .build() + Assertions.assertEquals(15466494, testAllOptions, "Testing all options") + } + + +} \ No newline at end of file diff --git a/Server/worldprops/default.conf b/Server/worldprops/default.conf index 56771d5ab..e04908f25 100644 --- a/Server/worldprops/default.conf +++ b/Server/worldprops/default.conf @@ -47,6 +47,7 @@ enable_botting = false max_adv_bots = 100 wild_pvp_enabled = false jad_practice_enabled = true +personalized_shops = true [paths] #path to the data folder, which contains the cache subfolder and such