public void TestNetPosition() { IEnumerable <Position> inputPositions = new List <Position> { new Position("Mike", "MS", "AAPL.N", 100, 20), new Position("Mike", "ML", "AAPL.N", 200, 20) }; //output positions IEnumerable <NetPosition> expectedNetPositions = new List <NetPosition> { new NetPosition("Mike", "AAPL.N", 300) }; IEnumerable <NetPosition> actualNetPositions = positionCalculator.calculateNetPositions(inputPositions); Assert.Equal(expectedNetPositions, actualNetPositions); }
static int Main(string[] args) { if (args.Length < 1) { Console.WriteLine("Usage: dotnet run <input_file_full_path>"); return(-1); } string inputfile = args[0]; IEnumerable <Position> inputPositions = null; try { inputPositions = parseInputFile(inputfile); } catch (IOException ioe) { Console.WriteLine("IOException while processing input files {0}", inputfile); Console.WriteLine("StackTrace: {0} ", ioe.StackTrace); return(-1); } catch (Exception e) { Console.WriteLine("The program has encountered an unexpected error"); Console.WriteLine("StackTrace: {0} ", e.StackTrace); return(-1); } PositionCalculator positionCalculator = new PositionCalculator(); IEnumerable <NetPosition> netPositions = positionCalculator.calculateNetPositions(inputPositions); IEnumerable <BoxedPosition> boxedPositions = positionCalculator.calculateBoxedPositions(inputPositions); Console.WriteLine("Net Positions: \n"); outputNetPositions(netPositions); Console.WriteLine("\n\nBox Positions: \n"); outputBoxedPositions(boxedPositions); return(0); }