Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package edu.pdx.cs.joy.phonebill;

import edu.pdx.cs.joy.InvokeMainTestCase;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import java.nio.file.Path;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;

/**
* Integration tests for {@link PhoneBillDAO#main(String[])}.
*/
class PhoneBillDAOIT extends InvokeMainTestCase {

private MainMethodResult invokeMain(String... args) {
return invokeMain(PhoneBillDAO.class, args);
}

@Test
void testNoCommandLineArguments() {
MainMethodResult result = invokeMain();

assertThat(result.getTextWrittenToStandardError(),
containsString("Usage: java PhoneBillDAO <db-file> <customer-name>"));
}

@Test
void testCreatesAndRetrievesPhoneBill(@TempDir Path tempDirectory) {
String databaseFile = tempDirectory.resolve("phonebill").toString();
String customerName = "Test Customer";

MainMethodResult result = invokeMain(databaseFile, customerName);

assertThat(result.getTextWrittenToStandardOut(),
containsString("Retrieved PhoneBill for customer: " + customerName));
}
}
Loading