|
From: Márcio V. d. S. <mv...@us...> - 2007-05-19 14:16:52
|
Update of /cvsroot/tail/Tail/src/test/net/sf/tail/runner In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv17390/src/test/net/sf/tail/runner Modified Files: HistoryRunnerTest.java Log Message: Criado teste para a classe HistoryRunner Index: HistoryRunnerTest.java =================================================================== RCS file: /cvsroot/tail/Tail/src/test/net/sf/tail/runner/HistoryRunnerTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HistoryRunnerTest.java 19 May 2007 13:23:22 -0000 1.1 --- HistoryRunnerTest.java 19 May 2007 14:16:51 -0000 1.2 *************** *** 1,5 **** package net.sf.tail.runner; ! import static org.junit.Assert.*; import org.junit.Before; --- 1,15 ---- package net.sf.tail.runner; ! import static org.junit.Assert.assertEquals; ! ! import java.util.List; ! ! import net.sf.tail.Indicator; ! import net.sf.tail.Operation; ! import net.sf.tail.OperationType; ! import net.sf.tail.Strategy; ! import net.sf.tail.Trade; ! import net.sf.tail.sample.SampleIndicator; ! import net.sf.tail.strategy.IndicatorOverIndicatorStrategy; import org.junit.Before; *************** *** 8,18 **** public class HistoryRunnerTest { @Before public void setUp() throws Exception { } @Test public void testRun() { ! fail("Not yet implemented"); } --- 18,49 ---- public class HistoryRunnerTest { + private Indicator<Double> first; + + 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)); ! } |