Add slayer plugin
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.slayer;
|
||||
|
||||
import static net.runelite.api.ChatMessageType.SERVER;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.events.ChatMessage;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.mockito.Answers.RETURNS_DEEP_STUBS;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SlayerTest
|
||||
{
|
||||
private static final String TASK_ONE = "You've completed one task; return to a Slayer master.";
|
||||
private static final String TASK_COMPLETE_NO_POINTS = "<col=ef1020>You've completed 3 tasks; return to a Slayer master.</col>";
|
||||
private static final String TASK_POINTS = "You've completed 9 tasks and received 0 points, giving you a total of 18,000; return to a Slayer master.";
|
||||
|
||||
private static final String TASK_COMPLETE = "You need something new to hunt.";
|
||||
private static final String TASK_CANCELED = "Your task has been cancelled.";
|
||||
|
||||
@Mock(answer = RETURNS_DEEP_STUBS)
|
||||
private RuneLite runeLite;
|
||||
|
||||
@Mock
|
||||
private SlayerConfig slayerConfig;
|
||||
|
||||
private Slayer slayerPlugin;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
RuneLite.setRunelite(runeLite);
|
||||
when(runeLite.getConfigManager().getConfig(Matchers.any(Class.class))).thenReturn(slayerConfig);
|
||||
when(slayerConfig.enabled()).thenReturn(true);
|
||||
|
||||
slayerPlugin = new Slayer();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneTask()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(SERVER, "Perterter", TASK_ONE, null);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(1, slayerPlugin.getStreak());
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoPoints()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(SERVER, "Perterter", TASK_COMPLETE_NO_POINTS, null);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(3, slayerPlugin.getStreak());
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPoints()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(SERVER, "Perterter", TASK_POINTS, null);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(9, slayerPlugin.getStreak());
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
assertEquals(18_000, slayerPlugin.getPoints());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplete()
|
||||
{
|
||||
slayerPlugin.setTaskName("cows");
|
||||
slayerPlugin.setAmount(42);
|
||||
|
||||
ChatMessage chatMessageEvent = new ChatMessage(SERVER, "Perterter", TASK_COMPLETE, null);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCancelled()
|
||||
{
|
||||
slayerPlugin.setTaskName("cows");
|
||||
slayerPlugin.setAmount(42);
|
||||
|
||||
ChatMessage chatMessageEvent = new ChatMessage(SERVER, "Perterter", TASK_CANCELED, null);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals("", slayerPlugin.getTaskName());
|
||||
assertEquals(0, slayerPlugin.getAmount());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user