mirror of
https://github.com/Aust1n46/VentureChat.git
synced 2025-05-22 18:09:06 +00:00
Added unit testing framework and first set of tests to VentureChat
This commit is contained in:
parent
d8b35fdfb9
commit
012ecda0ba
26
.classpath
26
.classpath
@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="MineverseChat"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/workspace/VentureChat Dependencies/Factions.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/workspace/VentureChat Dependencies/Heroes.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/workspace/VentureChat Dependencies/MassiveCore.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/workspace/VentureChat Dependencies/pircbotx-2.0.1.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/workspace/VentureChat Dependencies/PlaceholderAPI-2.8.2.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/workspace/VentureChat Dependencies/Towny.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/workspace/VentureChat Dependencies/Vault.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/workspace/VentureChat Dependencies/BungeeCord.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/plugins_1.13/ProtocolLib.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.14.1.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.7.10-SNAPSHOT-b1657.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.8.8-R0.1-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.9.4-R0.1-SNAPSHOT-latest.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.10-R0.1-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.11.2-R0.1-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.12.2.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.13.2.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.14.4.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Austin/Desktop/Mineverse Network/Servers/Hub/spigot-1.15.jar"/>
|
||||
<classpathentry kind="lib" path="lib"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
||||
/bin/
|
||||
/bin/
|
||||
/.classpath
|
||||
|
103
test/mineverse/Aust1n46/chat/utilities/FormatTest.java
Normal file
103
test/mineverse/Aust1n46/chat/utilities/FormatTest.java
Normal file
@ -0,0 +1,103 @@
|
||||
package mineverse.Aust1n46.chat.utilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mockito;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import mineverse.Aust1n46.chat.MineverseChat;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest( { MineverseChat.class })
|
||||
public class FormatTest {
|
||||
|
||||
private MineverseChat mockPlugin;
|
||||
private FileConfiguration mockConfig;
|
||||
|
||||
private List<String> filters;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
filters = new ArrayList<String>();
|
||||
filters.add("ass,donut");
|
||||
|
||||
mockPlugin = Mockito.mock(MineverseChat.class);
|
||||
mockConfig = Mockito.mock(FileConfiguration.class);
|
||||
|
||||
PowerMockito.mockStatic(MineverseChat.class);
|
||||
PowerMockito.when(MineverseChat.getInstance()).thenReturn(mockPlugin);
|
||||
Mockito.when(mockPlugin.getConfig()).thenReturn(mockConfig);
|
||||
Mockito.when(mockConfig.getStringList("filters")).thenReturn(filters);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
mockPlugin = null;
|
||||
mockConfig = null;
|
||||
filters = new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLastCodeSingleColor() {
|
||||
String input = "§cHello";
|
||||
String expectedResult = "§c";
|
||||
|
||||
String result = Format.getLastCode(input);
|
||||
|
||||
Assert.assertEquals(expectedResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLastCodeColorAfterFormat() {
|
||||
String input = "§o§cHello";
|
||||
String expectedResult = "§c";
|
||||
|
||||
String result = Format.getLastCode(input);
|
||||
|
||||
Assert.assertEquals(expectedResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLastCodeColorBeforeFormat() {
|
||||
String input = "§c§oHello";
|
||||
String expectedResult = "§c§o";
|
||||
|
||||
String result = Format.getLastCode(input);
|
||||
|
||||
Assert.assertEquals(expectedResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilterChat() {
|
||||
String test = "I am an ass";
|
||||
String expectedResult = "I am an donut";
|
||||
|
||||
String result = Format.FilterChat(test);
|
||||
Assert.assertEquals(expectedResult, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsValidColor() {
|
||||
String color = "red";
|
||||
|
||||
boolean result = Format.isValidColor(color);
|
||||
Assert.assertTrue(result);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsInvalidColor() {
|
||||
String color = "randomString";
|
||||
|
||||
boolean result = Format.isValidColor(color);
|
||||
Assert.assertFalse(result);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user