TicketTest.java 701 字节
Newer Older
沉默王二's avatar
沉默王二 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
package com.cmower.java_demo.thinkingjava.tdd;

import static org.junit.Assert.*;

import java.math.BigDecimal;

import org.junit.Before;
import org.junit.Test;

public class TicketTest {
	
	private Ticket ticket;

	@Before
	public void setUp() throws Exception {
		ticket = new Ticket();
	}

	@Test
	public void testOne() {
		BigDecimal total = new BigDecimal("99");
		
		assertEquals(total, ticket.sale(1));
	}
	
	@Test(expected=IllegalArgumentException.class)
	public void testNegative() {
		ticket.sale(-1);
	}
	
	@Test
	public void testZero() {
		assertEquals(BigDecimal.ZERO, ticket.sale(0));
	}
	
	@Test
	public void test1000() {
		assertEquals(new BigDecimal(99000), ticket.sale(1000));
	}

}