public double CalculateBmiFromCsv(string row)
        {
            var weightAndHeight = csvParser.Parse(row);

            double height = numberParser.Parse(weightAndHeight[0]);
            double weight = numberParser.Parse(weightAndHeight[1]);

            return(CalculateBmi(weight, height));
        }
    protected void ParseValue(string text)
    {
        if (String.IsNullOrWhiteSpace(text))
        {
            throw new AssemblerException("Expected constant value but none found");
        }

        text = text.Trim();

        StoreData(numberParser.Parse(text));
    }
        public string Evaluate(string input)
        {
            var tokens = input.Split(Separator);

            var operand1Name         = tokens[0];
            var operatorFunctionName = tokens[1];
            var operand2Name         = tokens[2];

            var operand1         = _numberParser.Parse(operand1Name);
            var operatorFunction = _operatorParser.Parse(operatorFunctionName);
            var operand2         = _numberParser.Parse(operand2Name);

            var result = operatorFunction.Evaluate(
                operand1,
                operand2);

            var output = _numberNamer.GetName(result);

            return(output);
        }
        private void TryConvert(string strNum)
        {
            long num;

            if (_innerDataValidator.ConvertStringToValidNumber(strNum, out num))
            {
                string result = _parser.Parse(num);
                _visualizator.SendAnswer(result, num);
            }
            else
            {
                _visualizator.SendInfo(Message.IncorectData);
            }
        }
Example #5
0
        public void ManuallyCreateSubstitutes()
        {
            // create both subs
            factory = Substitute.For <INumberParserFactory>();
            parser  = Substitute.For <INumberParser>();

            // now set up both separately
            factory.Create(',').Returns(parser);
            parser.Parse("an expression").Returns(new[] { 1, 2, 3 });

            Assert.AreEqual(
                factory.Create(',').Parse("an expression"),
                new[] { 1, 2, 3 });
        }
        public List <string> GenerateResultsBetween(int rangeStart, int rangeEnd)
        {
            var resultSet  = new List <string>();
            var inputRange = Enumerable.Range(rangeStart, rangeEnd).ToList();

            inputRange.ForEach(i =>
            {
                INumberParser numberParser
                    = Parsers
                      .First(p => i % p.Divisor == 0);

                resultSet.Add(numberParser.Parse(i));
            });

            return(resultSet);
        }
 public int Parse_ValidNumberString_ReturnsInt32Value(string stringValue)
 {
     return(_parser.Parse(stringValue));
 }
    public void Execute(ICpu cpu)
    {
        var text = EditNumber();

        cpu.Registers[0] = numberParser.Parse(text);
    }