public void GetKeyValuePairs_GivenUserInputString_ArrangeInDictionary()
        {
            //Arrange
            var input          = " Exchange USD/EUR 5 ";
            var processingData = new InputProcessingService();
            //Act
            var result = processingData.GetKeyValuePairs(input);

            //Assert
            result.Count.Should().Be(3);
            result["currency pair"].Should().NotBeNullOrEmpty();
            result["command"].Should().NotBeNullOrEmpty();
            //why
            //result["amount"].Should().NotBeNullOrEmpty();
        }
예제 #2
0
        private string GenerateReport(string template, LibraryDrop libraryDrop)
        {
            var         inputProcessor = new InputProcessingService(_inputs);
            TestRunDrop run;

            try
            {
                run = inputProcessor.Process();
            }
            catch (InvalidDataException e)
            {
                _errorConsole.WriteLine(e.Message);
                return(null);
            }

            string report = null;

            _standardConsole.WriteLine();
            _standardConsole.MarkupLine("Generating report");

            try
            {
                var reportGenerator = new ReportGenerator(new LibraryTestRun {
                    Run = run, Library = libraryDrop
                });
                report = reportGenerator.GenerateReport(template ?? Templates.MdMultiReport, out var errors);
                foreach (var error in errors)
                {
                    _standardConsole.MarkupLine($"[orange1]{error.Message}[/]");
                }
                _standardConsole.WriteLine();
                _standardConsole.MarkupLine("Finished generating report");
            }
            catch (SyntaxException e)
            {
                _errorConsole.WriteLine(e.Message);
            }
            catch (Exception e)
            {
                _errorConsole.WriteLine($"Unexpected error occurred while generating report {e.Message}");
            }

            return(report);
        }
예제 #3
0
        static void Main(string[] args)
        {
            var     path   = "C:\\Users\\kater\\Documents\\dot-net\\CurrencyExchangeRate\\CurrencyExchangeRate\\Data\\ExchangeRates.json";
            ILogger logger = new ConsoleLogger();
            DisplayMessageService displayMessageService = new DisplayMessageService(logger);

            displayMessageService.WriteCommand("Usage: Exchange <currency pair> <amount to exchange>");
            var       userResponse  = displayMessageService.ReadCommand();
            FetchData fetchData     = new FetchData();
            var       exchangeRates = fetchData.LoadJson(path);
            InputProcessingService inputProcessingService = new InputProcessingService();
            ParseInputService      parseInput             = new ParseInputService(inputProcessingService, exchangeRates);
            var userCurrencyInputObject = parseInput.ParseInput(userResponse);
            ExchangeRateCalculationService exchangeRateCalculationService = new ExchangeRateCalculationService();
            var result = exchangeRateCalculationService.CalculateExchangeRate(userCurrencyInputObject);

            displayMessageService.WriteCommand($"The result is {result}");
            displayMessageService.ReadCommand();
        }