Skip to content

Commit

Permalink
Merge pull request nus-cs2113-AY2324S2#35 from samuelory/Samuel-V0.3
Browse files Browse the repository at this point in the history
Added more JUnit Tests
  • Loading branch information
samuelory authored Mar 20, 2024
2 parents 2dd437e + 701380b commit eae7883
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
29 changes: 29 additions & 0 deletions src/test/java/florizz/command/AddBouquetTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package florizz.command;

import florizz.core.FlorizzException;
import florizz.core.Ui;
import florizz.objects.Bouquet;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;

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

public class AddBouquetTest {
@Test
void testAddCommandExecute(){
Bouquet testBouquet = new Bouquet("for testing");
Ui ui = new Ui();
ArrayList<Bouquet> controlList = new ArrayList<>();
ArrayList<Bouquet> testList = new ArrayList<>();
controlList.add(testBouquet);
Command testAddBouquetCommand = new AddBouquetCommand(testBouquet);
try {
testAddBouquetCommand.execute(testList, ui);
}
catch(FlorizzException error){
ui.printError(error);
}
assertEquals(controlList, testList);
}
}
31 changes: 31 additions & 0 deletions src/test/java/florizz/command/DeleteBouquetTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package florizz.command;

import florizz.core.FlorizzException;
import florizz.core.Ui;
import florizz.objects.Bouquet;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;

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

public class DeleteBouquetTest {
@Test
void testAddCommandExecute(){
Bouquet testBouquet = new Bouquet("for testing");
Ui ui = new Ui();
ArrayList<Bouquet> controlList = new ArrayList<>();
ArrayList<Bouquet> testList = new ArrayList<>();
controlList.add(testBouquet);
testList.add(testBouquet);
Command testDeleteBouquetCommand = new DeleteBouquetCommand(testBouquet);
controlList.remove(testBouquet);
try {
testDeleteBouquetCommand.execute(testList, ui);
}
catch(FlorizzException error){
ui.printError(error);
}
assertEquals(controlList, testList);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package florizz.objects;
package florizz.command;

import florizz.command.ExitCommand;
import florizz.core.Ui;
import florizz.objects.Bouquet;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package florizz.objects;
package florizz.command;

import florizz.command.HelpCommand;
import florizz.core.Ui;
import florizz.objects.Bouquet;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
Expand Down

0 comments on commit eae7883

Please sign in to comment.