Skip to content
Snippets Groups Projects

add two tests for Storage.getItemsOfCategorySortedByPrice

Closed Tomáš Votroubek requested to merge (removed):master into master
package cz.cvut.eshop.storage;
import cz.cvut.eshop.shop.Item;
import cz.cvut.eshop.shop.Order;
import cz.cvut.eshop.shop.ShoppingCart;
import cz.cvut.eshop.shop.StandardItem;
import org.junit.Test;
import java.util.Collection;
import java.util.Iterator;
import static org.junit.Assert.*;
@@ -153,4 +155,30 @@ public class StorageTest {
}
@Test
public void getItemsOfCategorySortedByPrice_containsOnlyDifferentCategory_shouldReturnEmptyColection() {
Storage storage = new Storage();
StandardItem item = new StandardItem(0, "", 0, "different", 0);
storage.insertItems(item, 0);
Collection<Item> items = storage.getItemsOfCategorySortedByPrice("");
assertTrue(items.isEmpty());
}
@Test
public void getItemsOfCategorySortedByPrice_twoUnsorted_shouldReturnSorted() {
Storage storage = new Storage();
StandardItem i1 = new StandardItem(0, "", 2, "", 0);
StandardItem i2 = new StandardItem(1, "", 1, "", 0);
storage.insertItems(i1, 0);
storage.insertItems(i2, 0);
Iterator<Item> items = storage.getItemsOfCategorySortedByPrice("").iterator();
assertTrue(items.next().getPrice() < items.next().getPrice());
}
}
\ No newline at end of file