public void EnsureOutputCanBeGeneratedWithMineralMap() { 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.CalculateCredits(parsedInput, metalToCreditsMap, galacticUnits); //var unitValue = calculator.CalculateValue(parsedInput, galacticUnits); var unitValue = new Dictionary <string, int>(); unitValue.Add("glob", 1); unitValue.Add("how many Silver is glob Gold ?", 0); var creditsvalue = new Dictionary <string, double>(); creditsvalue.Add("how manyy Silver is glob Gold ?", 0); var outputValue = calculator.GenerateOutput(unitValue, creditsvalue); //Assert.AreEqual(true, outputValue != ""); Assert.AreEqual(true, outputValue.Contains("I have no idea what you are talking about")); }
public void EnsureCalculatorCanBeInstatiated() { IInputParser documentParser = new InputParser(); IInterGalacticMapper mapper = new InterGalacticMapper(); IInputRetriever documentRetreiver = new FileReader(); InterGalacticCalculator calculator = new InterGalacticCalculator("", mapper, documentRetreiver, documentParser); Assert.IsInstanceOfType(calculator, typeof(InterGalacticCalculator)); }
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"); } }