|
From: Márcio V. d. S. <mv...@us...> - 2007-05-19 15:45:15
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/runner In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv20090/src/test/net/sf/tail/runner Modified Files: HistoryRunnerTest.java Log Message: Criado teste para o HistoryRunner Criado JustBuyOnceStrategy Criado MinvalueStopperStrategy Index: HistoryRunnerTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/runner/HistoryRunnerTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** HistoryRunnerTest.java 19 May 2007 14:16:51 -0000 1.2 --- HistoryRunnerTest.java 19 May 2007 15:45:14 -0000 1.3 *************** *** 2,8 **** import static org.junit.Assert.assertEquals; - import java.util.List; - import net.sf.tail.Indicator; import net.sf.tail.Operation; --- 2,6 ---- *************** *** 12,16 **** import net.sf.tail.sample.SampleIndicator; import net.sf.tail.strategy.IndicatorOverIndicatorStrategy; - import org.junit.Before; import org.junit.Test; --- 10,13 ---- *************** *** 21,49 **** private Indicator<Double> second; ! private Strategy strategy; ! @Before public void setUp() throws Exception { ! first = new SampleIndicator(new double[] {4,7,9,6,3,2,3,3}); ! second = new SampleIndicator(new double[] {3,6,10,8,2,1,4,4}); strategy = new IndicatorOverIndicatorStrategy(first, second); } @Test ! public void testRun() { HistoryRunner historyRunner = new HistoryRunner(8); List<Trade> trades = historyRunner.run(strategy); assertEquals(2, trades.size()); ! Operation entry = new Operation(2,OperationType.BUY); ! Operation exit = new Operation(4,OperationType.SELL); ! Trade trade = new Trade(entry,exit); assertEquals(trade, trades.get(0)); ! ! entry = new Operation(6,OperationType.BUY); ! exit = new Operation(7,OperationType.SELL); ! trade = new Trade(entry,exit); assertEquals(trade, trades.get(1)); ! } --- 18,46 ---- private Indicator<Double> second; ! private Strategy strategy; ! @Before public void setUp() throws Exception { ! first = new SampleIndicator(new double[] { 4, 7, 9, 6, 3, 2, 3, 3 }); ! second = new SampleIndicator(new double[] { 3, 6, 10, 8, 2, 1, 4, 4 }); strategy = new IndicatorOverIndicatorStrategy(first, second); } @Test ! public void testRunMethod() { HistoryRunner historyRunner = new HistoryRunner(8); List<Trade> trades = historyRunner.run(strategy); assertEquals(2, trades.size()); ! Operation entry = new Operation(2, OperationType.BUY); ! Operation exit = new Operation(4, OperationType.SELL); ! Trade trade = new Trade(entry, exit); assertEquals(trade, trades.get(0)); ! ! entry = new Operation(6, OperationType.BUY); ! exit = new Operation(7, OperationType.SELL); ! trade = new Trade(entry, exit); assertEquals(trade, trades.get(1)); ! } |