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 TestNetPosition() { var dataFile = new DataFile(); dataFile.LongPositions.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")); dataFile.TraderPositions.AddRange(dataFile.LongPositions.Union(dataFile.ShortPositions)); var netPositionAsString = dataFile.GetNetPosition(); var netPositions = netPositionAsString.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToList(); if (!netPositions.Contains("aTrader,aSymbol,-120") || !netPositions.Contains("aTrader,aSymbol1,-440")) { throw new InvalidOperationException("Net Position failed"); } }