added example tests

This commit is contained in:
schwarz
2021-04-30 10:21:08 +02:00
parent e9458859bf
commit 87c84269d9
4 changed files with 38 additions and 1 deletions

View File

@@ -0,0 +1,11 @@
<html>
<h1>Statement for BigCo</h1>
<table>
<tr><th>play</th><th>seats</th><th>cost</th></tr>
<tr><td>Hamlet</td><td>55</td><td>$650.00</td></tr>
<tr><td>As You Like It</td><td>35</td><td>$580.00</td></tr>
<tr><td>Othello</td><td>40</td><td>$500.00</td></tr>
</table>
<p>Amount owed is <em>$1,730.00</em></p>
<p>You earned <em>47</em> credits</p>
</html>

View File

@@ -9,7 +9,7 @@ import static org.approvaltests.Approvals.verify;
public class StatementPrinterTests {
@Test
void exampleStatement() {
void exampleStatementPlainText() {
Map<String, Play> plays = Map.of(
"hamlet", new Play("Hamlet", "tragedy"),
"as-like", new Play("As You Like It", "comedy"),
@@ -26,6 +26,25 @@ public class StatementPrinterTests {
verify(result);
}
@Test
void exampleStatementHtml() {
Map<String, Play> plays = Map.of(
"hamlet", new Play("Hamlet", "tragedy"),
"as-like", new Play("As You Like It", "comedy"),
"othello", new Play("Othello", "tragedy"));
Invoice invoice = new Invoice("BigCo", List.of(
new Performance("hamlet", 55),
new Performance("as-like", 35),
new Performance("othello", 40)));
StatementPrinter statementPrinter = new StatementPrinter();
// Not implemented yet
// var result = statementPrinter.printAsHtml(invoice, plays);
// verify(result);
}
@Test
void statementWithNewPlayTypes() {
Map<String, Play> plays = Map.of(
@@ -37,6 +56,8 @@ public class StatementPrinterTests {
new Performance("as-like", 55)));
StatementPrinter statementPrinter = new StatementPrinter();
// Not implemented yet
Assertions.assertThrows(Error.class, () -> {
statementPrinter.print(invoice, plays);
});

View File

@@ -0,0 +1,5 @@
Statement for BigCo
Henry V: $100.00 (53 seats)
As You Like It: $100.00 (55 seats)
Amount owed is $200.00
You earned 48 credits