Updated tests.
This commit is contained in:
parent
968823828a
commit
1035f5ba05
4 changed files with 29 additions and 21 deletions
|
@ -4,13 +4,17 @@
|
|||
<Whitelist>
|
||||
<ID>LongParameterList:AbstractCommand.kt$AbstractCommand$( bot: Mobibot, sender: String, login: String, args: String, isOp: Boolean, isPrivate: Boolean )</ID>
|
||||
<ID>LongParameterList:Comment.kt$Comment$( bot: Mobibot, cmd: String, sender: String, isOp: Boolean, entry: EntryLink, index: Int, commentIndex: Int )</ID>
|
||||
<ID>LongParameterList:Comment.kt$Comment$( bot: Mobibot, sender: String, isOp: Boolean, entry: EntryLink, index: Int, commentIndex: Int )</ID>
|
||||
<ID>LongParameterList:Comment.kt$Comment$(bot: Mobibot, cmd: String, sender: String, entry: EntryLink, index: Int, commentIndex: Int)</ID>
|
||||
<ID>MagicNumber:Comment.kt$Comment$3</ID>
|
||||
<ID>MagicNumber:Cycle.kt$Cycle$10</ID>
|
||||
<ID>MagicNumber:Ignore.kt$Ignore$8</ID>
|
||||
<ID>MagicNumber:Modules.kt$Modules$7</ID>
|
||||
<ID>MagicNumber:Recap.kt$Recap.Companion$10</ID>
|
||||
<ID>MagicNumber:UrlMgr.kt$UrlMgr$1000L</ID>
|
||||
<ID>MagicNumber:UrlMgr.kt$UrlMgr$60L</ID>
|
||||
<ID>MagicNumber:View.kt$View$8</ID>
|
||||
<ID>NestedBlockDepth:Comment.kt$Comment$commandResponse</ID>
|
||||
<ID>NestedBlockDepth:UrlMgr.kt$UrlMgr$commandResponse</ID>
|
||||
</Whitelist>
|
||||
</SmellBaseline>
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
package net.thauvin.erik.mobibot.modules;
|
||||
|
||||
import net.thauvin.erik.mobibot.Utils;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
@ -46,9 +47,9 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class CalcTest {
|
||||
@Test
|
||||
public void testCalc() {
|
||||
assertThat(Calc.calc("1 + 1")).as("calc(1+1)").isEqualTo("1+1 = 2");
|
||||
assertThat(Calc.calc("1 -3")).as("calc(1 -3)").isEqualTo("1-3 = -2");
|
||||
assertThat(Calc.calc("pi+π+e+φ")).as("calc(pi+π+e+φ)").isEqualTo("pi+π+e+φ = 10.62");
|
||||
assertThat(Calc.calc("1 + 1")).as("calc(1+1)").isEqualTo("1+1 = %s", Utils.bold(2));
|
||||
assertThat(Calc.calc("1 -3")).as("calc(1 -3)").isEqualTo("1-3 = %s", Utils.bold(-2));
|
||||
assertThat(Calc.calc("pi+π+e+φ")).as("calc(pi+π+e+φ)").isEqualTo("pi+π+e+φ = %s", Utils.bold("10.62"));
|
||||
assertThat(Calc.calc("one + one")).as("calc(one + one)").startsWith("No idea.");
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
package net.thauvin.erik.mobibot.modules;
|
||||
|
||||
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
|
||||
import net.thauvin.erik.mobibot.msg.ErrorMessage;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
@ -46,26 +46,28 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
* @since 1.0
|
||||
*/
|
||||
public class CurrencyConverterTest {
|
||||
@Test
|
||||
public void testCurrencyConvertererImpl() {
|
||||
AbstractModuleTest.testAbstractModule(new CurrencyConverter());
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ModuleException.class)
|
||||
public void testException() throws ModuleException {
|
||||
CurrencyConverter.convertCurrency("100 BLA to USD");
|
||||
@BeforeClass
|
||||
public void before() throws ModuleException {
|
||||
CurrencyConverter.loadRates();
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressFBWarnings("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS")
|
||||
public void testConvertCurrency() throws ModuleException {
|
||||
public void testConvertCurrency() {
|
||||
assertThat(CurrencyConverter.convertCurrency("100 USD to EUR").getMessage())
|
||||
.as("100 USD to EUR").startsWith("100.00 USD = ");
|
||||
assertThat(CurrencyConverter.convertCurrency("100 USD to USD"))
|
||||
.as("100 USD to USD").isInstanceOf(ErrorMessage.class);
|
||||
assertThat(CurrencyConverter.convertCurrency(CurrencyConverter.CURRENCY_RATES_KEYWORD).isNotice())
|
||||
.as(CurrencyConverter.CURRENCY_RATES_KEYWORD + " is notice").isTrue();
|
||||
assertThat(CurrencyConverter.convertCurrency(CurrencyConverter.CURRENCY_RATES_KEYWORD).getMessage())
|
||||
.as(CurrencyConverter.CURRENCY_RATES_KEYWORD).contains("USD: ");
|
||||
.as("100 USD to EUR").matches("100\\.00 USD = \\d{2,3}\\.\\d{2} EUR");
|
||||
assertThat(CurrencyConverter.convertCurrency("100 USD to USD").getMessage())
|
||||
.as("100 USD to USD").contains("You're kidding, right?");
|
||||
assertThat(CurrencyConverter.convertCurrency("100 USD").getMessage())
|
||||
.as("100 USD").contains("Invalid query.");
|
||||
assertThat(CurrencyConverter.currencyRates().size())
|
||||
.as("currencyRates().size() == 33").isEqualTo(33);
|
||||
assertThat(CurrencyConverter.currencyRates())
|
||||
.as("currencyRates().get(EUR)").contains(" EUR: 1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCurrencyConvertererImpl() {
|
||||
AbstractModuleTest.testAbstractModule(new CurrencyConverter());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
package net.thauvin.erik.mobibot.modules;
|
||||
|
||||
import net.thauvin.erik.mobibot.Utils;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
@ -46,7 +47,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
public class WordTimeTest {
|
||||
@Test
|
||||
public void testWorldTime() {
|
||||
assertThat(WorldTime.worldTime("PST").getMessage()).as("PST").endsWith("Los Angeles");
|
||||
assertThat(WorldTime.worldTime("PST").getMessage()).as("PST").endsWith(Utils.bold("Los Angeles"));
|
||||
assertThat(WorldTime.worldTime("BLAH").isError()).as("BLAH").isTrue();
|
||||
assertThat(WorldTime.worldTime("BEATS").getMessage()).as("BEATS").contains("@");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue