You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.7 KiB
75 lines
1.7 KiB
/**
|
|
* Copyright (C) 2021, Tim Holloway
|
|
*
|
|
* Date written: Dec 2, 2021
|
|
* Author: Tim Holloway <timh@mousetech.com>
|
|
*/
|
|
package com.mousetech.gourmetj.jsf.util;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import com.mousetech.gourmetj.IngredientUI;
|
|
import com.mousetech.gourmetj.persistence.model.Ingredient;
|
|
|
|
/**
|
|
* @author timh
|
|
* @since Dec 2, 2021
|
|
*/
|
|
public class IngredientUITest {
|
|
|
|
/**
|
|
* Test method for {@link com.mousetech.gourmetj.jsf.util.IngredientUI#getDisplayAmount()}.
|
|
*/
|
|
@Test
|
|
public void testGetDisplayAmount() {
|
|
IngredientUI ui = new IngredientUI(new Ingredient());
|
|
|
|
ui.setAmount(12.0d);
|
|
assertEquals("12", ui.getDisplayAmount());
|
|
|
|
ui.setAmount(2.66666d);
|
|
assertEquals( "2⅔", ui.getDisplayAmount());
|
|
|
|
ui.setAmount(4.5);
|
|
assertEquals("4½", ui.getDisplayAmount());
|
|
|
|
ui.setAmount(3.57d);
|
|
assertEquals("3.57", ui.getDisplayAmount());
|
|
}
|
|
|
|
/**
|
|
* Test method for {@link com.mousetech.gourmetj.jsf.util.IngredientUI#setDisplayAmount(java.lang.String)}.
|
|
*/
|
|
@Test
|
|
public void testSetDisplayAmount() {
|
|
IngredientUI ui = new IngredientUI(new Ingredient());
|
|
|
|
ui.setDisplayAmount("3 - 1/2");
|
|
assertEquals(3.5d, ui.getAmount(), 0.001);
|
|
|
|
ui.setDisplayAmount("2⅔");
|
|
assertEquals(2.6666, ui.getAmount(), 0.001);
|
|
|
|
ui.setDisplayAmount("9");
|
|
assertEquals(9.0d, ui.getAmount(), 0.001);
|
|
}
|
|
|
|
/**
|
|
* Test method for {@link com.mousetech.gourmetj.jsf.util.IngredientUI#getOptionalCB()}.
|
|
*/
|
|
@Test
|
|
public void testGetOptionalCB() {
|
|
//fail("Not yet implemented");
|
|
}
|
|
|
|
/**
|
|
* Test method for {@link com.mousetech.gourmetj.jsf.util.IngredientUI#setOptionalCB(boolean)}.
|
|
*/
|
|
@Test
|
|
public void testSetOptionalCB() {
|
|
//fail("Not yet implemented");
|
|
}
|
|
|
|
}
|
|
|