package com.szpg.db.test;

import static org.junit.Assert.assertEquals;

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

import com.szpg.db.dao.PgAcuRdcmdDao;
import com.szpg.db.dao.impl.PgAcuRdcmdDaoImpl;
import com.szpg.db.data.PgAcuRdcmd;
import com.szpg.plc.message.AppMessageConstants;

public class PgAcuRdcmdDaoTest {
	
	private PgAcuRdcmdDao dao;
	
	@Before
	public void init() {
		dao = new PgAcuRdcmdDaoImpl();
	}

//	@Test
	public void testAdd() {
		PgAcuRdcmd cmd = new PgAcuRdcmd();
		cmd.setCmd_type(AppMessageConstants.CMD_TYPE_READCH4VALUE);
		cmd.setDest_acu_code("YXL.ACU001");
		
		assertEquals(1, dao.addCmdRecord(cmd));
	}
	
	@Test
	public void testFindLatestCmdByDestAndType() {
		assertEquals("b6da51ca612b408daf78c06c026279ed", dao.findLatestCmdByDestAndType("006B00", "10").getId());
	}

//	@Test
	public void testFindAll() {
		assertEquals(1, dao.findAll().size());
	}
	
//	@Test
	public void testUpdateTimeout() {
		assertEquals(1, dao.updateCmdRecordTimeout("1e37d707d1554a4ea2c9d8dc273b99d5"));
	}
	
//	@Test
	public void testDelete() {
		assertEquals(1, dao.deleteCmdRecord("1e37d707d1554a4ea2c9d8dc273b99d5"));
	}
}
