Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Unit Testing for Calendar Commands. #214

Merged
merged 1 commit into from
Nov 5, 2019
Merged
Show file tree
Hide file tree
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
41 changes: 41 additions & 0 deletions src/main/java/seedu/address/commons/stub/UiManagerStub.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package seedu.address.commons.stub;

import seedu.address.logic.UiManager;
import seedu.address.model.CalendarDate;

/**
* Represents a stub for the UiManager that is used for testing purpose only.
* @see UiManager
*/
public class UiManagerStub extends UiManager {

@Override
public void viewCalendar(CalendarDate calendarDate) {
return;
}

@Override
public void viewList() {
return;
}

@Override
public void viewLog() {
return;
}

@Override
public void viewDay(CalendarDate calendarDate) {
return;
}

@Override
public void viewWeek(CalendarDate calendarDate) {
return;
}

@Override
public void viewMonth(CalendarDate calendarDate) {
return;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ RequiredArgumentList defineCommandArguments() {
return null;
}

// TODO: Currently has a bug when typing "calendar" only. Either add new command or fix this.
@Override
Map<String, OptionalArgumentList> defineCommandOptions() {
return Map.of(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package seedu.address.logic.commands;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static seedu.address.logic.commands.CalendarViewCommandBuilder.OPTION_CALENDAR_SCREEN_DATE;

import org.junit.jupiter.api.Test;

import seedu.address.commons.stub.UiManagerStub;

class CalendarViewCommandTest {
@Test
void build_fullCommand_success() {
String calendarDate = "11/1111";
assertDoesNotThrow(() -> {
UiManagerStub uiManager = new UiManagerStub();
Command command = CalendarViewCommand.newBuilder(uiManager)
.acceptSentence(OPTION_CALENDAR_SCREEN_DATE)
.acceptSentence(calendarDate)
.build();

command.execute();
});

}

@Test
void build_emptyCommand_success() {
assertDoesNotThrow(() -> {
UiManagerStub uiManager = new UiManagerStub();
Command command = CalendarViewCommand.newBuilder(uiManager)
.build();

command.execute();
});
}
}
39 changes: 39 additions & 0 deletions src/test/java/seedu/address/logic/commands/DayViewCommandTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package seedu.address.logic.commands;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.junit.jupiter.api.Test;

import seedu.address.commons.stub.UiManagerStub;
import seedu.address.logic.UiManager;
import seedu.address.logic.commands.exceptions.ArgumentException;

class DayViewCommandTest {

@Test
void build_fullCommand_success() {
String calendarDate = "11/11/1111";
assertDoesNotThrow(() -> {
UiManagerStub uiManager = new UiManagerStub();

Command command = DayViewCommand.newBuilder(uiManager)
.acceptSentence(calendarDate)
.build();

command.execute();
});
}

@Test
void execute_emptyCommand_failure() {
assertThrows(ArgumentException.class, () -> {
UiManager uiManager = new UiManager();

Command command = DayViewCommand.newBuilder(uiManager)
.build();

command.execute();
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package seedu.address.logic.commands;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

import org.junit.jupiter.api.Test;

import seedu.address.commons.stub.UiManagerStub;

class ListViewCommandTest {

@Test
void build_fullCommand_success() {
assertDoesNotThrow(() -> {
UiManagerStub uiManager = new UiManagerStub();
Command command = ListViewCommand.newBuilder(uiManager)
.build();

command.execute();
});

}
}
22 changes: 22 additions & 0 deletions src/test/java/seedu/address/logic/commands/LogViewCommandTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package seedu.address.logic.commands;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

import org.junit.jupiter.api.Test;

import seedu.address.commons.stub.UiManagerStub;

class LogViewCommandTest {

@Test
void build_fullCommand_success() {
assertDoesNotThrow(() -> {
UiManagerStub uiManager = new UiManagerStub();
Command command = LogViewCommand.newBuilder(uiManager)
.build();

command.execute();
});

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package seedu.address.logic.commands;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.junit.jupiter.api.Test;

import seedu.address.commons.stub.UiManagerStub;
import seedu.address.logic.UiManager;
import seedu.address.logic.commands.exceptions.ArgumentException;

class MonthViewCommandTest {

@Test
void build_fullCommand_success() {
String calendarDate = "11/1111";
assertDoesNotThrow(() -> {
UiManagerStub uiManager = new UiManagerStub();

Command command = MonthViewCommand.newBuilder(uiManager)
.acceptSentence(calendarDate)
.build();

command.execute();
});
}

@Test
void execute_emptyCommand_failure() {
assertThrows(ArgumentException.class, () -> {
UiManager uiManager = new UiManager();

Command command = MonthViewCommand.newBuilder(uiManager)
.build();

command.execute();
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package seedu.address.logic.commands;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.junit.jupiter.api.Test;

import seedu.address.commons.stub.UiManagerStub;
import seedu.address.logic.UiManager;
import seedu.address.logic.commands.exceptions.ArgumentException;

class WeekViewCommandTest {

@Test
void build_fullCommand_success() {
String calendarDate = "11/11/1111";
assertDoesNotThrow(() -> {
UiManagerStub uiManager = new UiManagerStub();

Command command = WeekViewCommand.newBuilder(uiManager)
.acceptSentence(calendarDate)
.build();

command.execute();
});
}

@Test
void execute_emptyCommand_failure() {
assertThrows(ArgumentException.class, () -> {
UiManager uiManager = new UiManager();

Command command = WeekViewCommand.newBuilder(uiManager)
.build();

command.execute();
});
}
}