Demo entry 6688523

java

   

Submitted by anonymous on Jan 03, 2018 at 13:32
Language: Java. Code size: 3.8 kB.

package sellerJunit;

import static org.junit.Assert.*;

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

public class SaleMachinePathTest {

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testOperationS1() {//有零钱,有啤酒,客户投币5角,选择啤酒
		SaleMachine saleMachine1 = new SaleMachine(6,6,6,6);
		String expectedResuilt = "Input Information \n"
				+"Type: Beer; Money: 5 Jiao; Change: 0\n\n";
		assertEquals(expectedResuilt, saleMachine1.operation("Beer", "5J"));
	}

	@Test
	public void testOperationS2() {//有零钱,没有啤酒,客户投币5角,选择啤酒
		SaleMachine saleMachine2 = new SaleMachine(6,6,0,6);
		String expectedResuilt = "Failure Information \n"
				+"Beer Shortage";
		assertEquals(expectedResuilt, saleMachine2.operation("Beer", "5J"));
	}
	
	@Test
	public void testOperationS3() {//有零钱,有橙汁,客户投币5角,选择橙汁
		SaleMachine saleMachine3 = new SaleMachine(6,6,6,6);
		String expectedResuilt = "Input Information \n"
				+"Type: OrangeJuice; Money: 5 Jiao; Change: 0\n\n";
		assertEquals(expectedResuilt, saleMachine3.operation("OrangeJuice", "5J"));
	}
	
	@Test
	public void testOperationS4() {//有零钱,没有橙汁,客户投币5角,选择橙汁
		SaleMachine saleMachine4 = new SaleMachine(6,6,6,0);
		String expectedResuilt = "Failure Information \n"
				+"Type Error";
		assertEquals(expectedResuilt, saleMachine4.operation("OrangeJuice", "5J"));
	}
	
	@Test
	public void testOperationS5() {//有零钱,有啤酒,客户投币5角,没有选择
		SaleMachine saleMachine5 = new SaleMachine(6,6,6,6);
		String expectedResuilt = "Failure Information \n"
				+"Type Error";
		assertEquals(expectedResuilt, saleMachine5.operation("null", "5J"));
	}
	
	@Test
	public void testOperationS6() {//有零钱,有啤酒,客户投币1元,选择啤酒
		SaleMachine saleMachine6 = new SaleMachine(6,6,6,6);
		String expectedResuilt = "Input Information \n"
				+"Type: Beer; Money: 1 Yuan; Change: 5 Jiao\n\n";
		assertEquals(expectedResuilt, saleMachine6.operation("Beer", "1Y"));
	}
	
	@Test
	public void testOperationS7() {//有零钱,没有啤酒,客户投币1元,选择啤酒
		SaleMachine saleMachine7 = new SaleMachine(6,6,0,6);
		String expectedResuilt = "Input Information \n"
				+"Type: Beer; Money: 1 Yuan; Change: 5 Jiao\n\n";
		assertEquals(expectedResuilt, saleMachine7.operation("Beer", "1Y"));
	}
	
	@Test
	public void testOperationS8() {//有零钱,有橙汁,客户投币1元,选择橙汁
		SaleMachine saleMachine8 = new SaleMachine(6,6,6,6);
		String expectedResuilt = "Input Information \n"
				+"Type: OrangeJuice; Money: 1 Yuan; Change: 5 Jiao\n\n";
		assertEquals(expectedResuilt, saleMachine8.operation("OrangeJuice", "1Y"));
	}
	
	@Test
	public void testOperationS9() {//有零钱,没有橙汁,客户投币1元,选择橙汁
		SaleMachine saleMachine9 = new SaleMachine(6,6,6,0);
		String expectedResuilt = "Failure Information \n"
				+"OrangeJuice Shortage";
		assertEquals(expectedResuilt, saleMachine9.operation("OrangeJuice", "1Y"));
	}
	
	@Test
	public void testOperationS10() {//有零钱,有啤酒,客户投币1元,没有选择
		SaleMachine saleMachine10 = new SaleMachine(6,6,6,6);
		String expectedResuilt = "Failure Information \n"
				+"Type Error";
		assertEquals(expectedResuilt, saleMachine10.operation("null", "1Y"));
	}
	
	@Test
	public void testOperationS11() {//没有零钱,有啤酒,客户投币1元,选择啤酒
		SaleMachine saleMachine11 = new SaleMachine(0,6,6,6);
		String expectedResuilt = "Failure Information \n"
				+"Change Shortage";
		assertEquals(expectedResuilt, saleMachine11.operation("Beer", "1Y"));
	}
	
	@Test
	public void testOperationS12() {//有零钱,有橙汁,客户投币1角,选择橙汁
		SaleMachine saleMachine12 = new SaleMachine(6,6,6,6);
		String expectedResuilt = "Failure Information \n"
				+"Money Error";
		assertEquals(expectedResuilt, saleMachine12.operation("OrangeJuice", "1J"));
	}
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).