public void EnsureCalculatorCanGetText() { IInputParser documentParser = new InputParser(); IInterGalacticMapper mapper = new InterGalacticMapper(); IInputRetriever documentRetreiver = new FileReader(); InterGalacticCalculator calculator = new InterGalacticCalculator("", mapper, documentRetreiver, documentParser); var text = calculator.GetInputFromFile("..\\..\\..\\MerchantsGuideToTheGalaxy\\Resources\\input.txt"); Assert.IsNotNull(text); Assert.AreEqual(true, text.Contains("glob")); }
public void EnsureCalculateValueFromInput() { IInputParser documentParser = new InputParser(); IInterGalacticMapper mapper = new InterGalacticMapper(); IInputRetriever documentRetreiver = new FileReader(); InterGalacticCalculator calculator = new InterGalacticCalculator("", mapper, documentRetreiver, documentParser); var text = calculator.GetInputFromFile("..\\..\\..\\MerchantsGuideToTheGalaxy\\Resources\\input.txt"); var parsedInput = calculator.ParseInputFromFile(text); var galacticUnits = calculator.MapUnits(parsedInput); var metalToCreditsMap = calculator.MapMetalToCredits(parsedInput, galacticUnits); var value = calculator.CalculateValue(parsedInput, galacticUnits); Assert.AreEqual(true, value.Count > 0); }
public void EnsureCalculatorCanMapUnits() { IInputParser documentParser = new InputParser(); IInterGalacticMapper mapper = new InterGalacticMapper(); IInputRetriever documentRetreiver = new FileReader(); InterGalacticCalculator calculator = new InterGalacticCalculator("", mapper, documentRetreiver, documentParser); var text = calculator.GetInputFromFile("..\\..\\..\\MerchantsGuideToTheGalaxy\\Resources\\input.txt"); var parsedInput = calculator.ParseInputFromFile(text); var galacticUnits = calculator.MapUnits(parsedInput); Assert.IsNotNull(galacticUnits); Assert.AreEqual(true, galacticUnits.Count() > 0); Assert.AreEqual(true, galacticUnits.Count() == 7); }
//Location to read input from."..\\..\\..\\MerchantsGuideToTheGalaxy\\Resources\\input.txt") static void Main(string[] args) { while (true) { IInputRetriever documentRetreiver = new FileReader(); IInputParser documentParser = new InputParser(); IInterGalacticMapper mapper = new InterGalacticMapper(); InterGalacticCalculator calculator = new InterGalacticCalculator("", mapper, documentRetreiver, documentParser); Console.Write("Welcome to the InterGalactic calculator,please provide the file location with your input? "); var consoleText = Console.ReadLine(); if (consoleText == "exit") { break; } var fileInput = calculator.GetInputFromFile(consoleText); if (String.IsNullOrEmpty(fileInput)) { break; } var parsedInput = calculator.ParseInputFromFile(fileInput); var galacticUnits = calculator.MapUnits(parsedInput); var metalToCreditsMap = calculator.MapMetalToCredits(parsedInput, galacticUnits); var creditsValue = calculator.CalculateCredits(parsedInput, metalToCreditsMap, galacticUnits); var unitsValue = calculator.CalculateValue(parsedInput, galacticUnits); var outputValue = calculator.GenerateOutput(unitsValue, creditsValue); Console.WriteLine(outputValue); Console.WriteLine("\r\n"); } }