Beispiel #1
0
 public bool AreWordsValidAliases(string[] words)
 {
     foreach (string word in words)
     {
         if (!aliasMap.Exists(word))
         {
             return(false);
         }
     }
     return(true);
 }
        public void AliasExpressionTest()
        {
            AliasMapper     aliasMap   = new AliasMapper();
            AliasExpression expression = new AliasExpression(aliasMap);

            Assert.IsTrue(expression.Match("glob is C"));
            Assert.IsFalse(expression.Match("glob is N"));
            expression.Execute("glob is C");
            Assert.IsTrue(aliasMap.Exists("glob"));
            Assert.IsTrue(String.Equals(aliasMap.GetValueForAlias("glob"), "C"));
        }
        public void AliasExpressionTest()
        {
            AliasMapper         aliasMap   = new AliasMapper();
            AliasExpressionType expression = new AliasExpressionType(aliasMap);

            Assert.True(expression.Match("glob is C"));
            Assert.False(expression.Match("glob is N"));
            expression.Execute("glob is C");
            Assert.True(aliasMap.Exists("glob"));
            Assert.Equal("C", aliasMap.GetValueForAlias("glob"));
        }
Beispiel #4
0
        public void Execute(string input)
        {
            //Remove question mark
            input = input.Substring(0, input.Length - 1);

            StringBuilder sb = new StringBuilder();

            string[] parts = input.Split(new string[] { " is " }, StringSplitOptions.RemoveEmptyEntries);
            string[] words = parts[1].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string word in words)
            {
                if (!aliasMap.Exists(word))
                {
                    Console.WriteLine(String.Format("Error while processing this input: {0}", input));
                    return;
                }
                sb.Append(aliasMap.GetValueForAlias(word));
            }

            Console.WriteLine(String.Format("{0} is {1}", parts[1], converter.ConvertToDecimal(sb.ToString())));
        }
        public void Execute(string input)
        {
            //Remove question mark
            input = input.Substring(0, input.Length - 1);

            StringBuilder sb = new StringBuilder();

            string[] parts = Regex.Split(input, Constant.ExpressionSplitter, RegexOptions.IgnoreCase);
            string[] words = parts[1].Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string word in words)
            {
                if (!_aliasMap.Exists(word))
                {
                    Console.WriteLine(String.Format("Error while processing this input: {0}", input));
                    return;
                }
                sb.Append(_aliasMap.GetValueForAlias(word));
            }

            Console.WriteLine(String.Format("{0}{1}{2}", parts[1], Constant.ExpressionSplitter, _converter.ToDecimal(sb.ToString())));
        }