public bool AreWordsValidCommodities(string[] words) { foreach (string word in words) { if (!_wordMap.Exists(word)) { return(false); } } return(true); }
public void UnitExpressionTest() { RomanPseudonymMapper pseudonymMap = new RomanPseudonymMapper(); RomanConverter converter = new RomanConverter(); WordMapper wordMap = new WordMapper(); pseudonymMap.AddPseudonym("glob", "I"); pseudonymMap.AddPseudonym("pish", "X"); ExpressionValidationHelper helper = new ExpressionValidationHelper(pseudonymMap, wordMap); UnitExpression expression = new UnitExpression(pseudonymMap, wordMap, converter, helper); expression.Execute("pish glob Iron is 110 Credits"); Assert.True(wordMap.Exists("Iron")); Assert.Equal <double>(10, wordMap.GetPriceByWord("Iron")); expression.Execute("glob pish Iron is 6300 Credits"); Assert.Equal <double>(700, wordMap.GetPriceByWord("Iron")); }