public static void Main() { var dataFileTest = new DataFileTest(); dataFileTest.TestTraderPositionCreation(); dataFileTest.TestPositionAssignment(); dataFileTest.TestNetPosition(); dataFileTest.TestBoxedPosition(); var dataFile = new DataFile("C:\\Users\\petere\\Documents\\Visual Studio 2013\\Projects\\ConsoleApplication1\\PositionCalculator\\test_data.csv"); string netPosition = dataFile.GetNetPosition(); string boxPosition = dataFile.GetBoxedPosition(); using ( var streamWriter = new StreamWriter( @"C:\Users\petere\Documents\Visual Studio 2013\Projects\ConsoleApplication1\PositionCalculator\net_positions_expected.csv") ) { streamWriter.Write(netPosition); } using ( var streamWriter = new StreamWriter( @"C:\Users\petere\Documents\Visual Studio 2013\Projects\ConsoleApplication1\PositionCalculator\boxed_positions_expected.csv") ) { streamWriter.Write(boxPosition); } Console.WriteLine(netPosition); Console.WriteLine("BOX-----------------------------------------------"); Console.WriteLine(boxPosition); Console.ReadLine(); }
public void TestBoxedPosition() { var dataFile = new DataFile(); dataFile.ShortPositions.Add(new TraderPosition("aTrader,aBroker2,aSymbol,-520,200")); dataFile.LongPositions.Add(new TraderPosition("aTrader,aBroker1,aSymbol,520,500")); dataFile.ShortPositions.Add(new TraderPosition("aTrader,aBroker1,aSymbol,-120,500")); dataFile.ShortPositions.Add(new TraderPosition("aTrader,aBroker2,aSymbol1,-220,500")); dataFile.ShortPositions.Add(new TraderPosition("aTrader,aBroker2,aSymbol1,-220,500")); var boxPositionAsString = dataFile.GetBoxedPosition(); var boxPositions = boxPositionAsString.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToList(); if (boxPositions[0] != "aTrader,aSymbol,520") { throw new InvalidOperationException("Boxed Position failed"); } }