public void IsNamedValueShouldReturnFalseIfKeyIsNotANamedValue() { var dict = new Dictionary <string, object>(); dict.Add("A", "B"); _excelDataProvider.Stub(x => x.GetWorkbookNameValues()) .Return(dict); var nameValueProvider = new NameValueProvider(_excelDataProvider); var result = nameValueProvider.IsNamedValue("C"); Assert.IsFalse(result); }
public void ReloadShouldReloadDataFromExcelDataProvider() { var dict = new Dictionary <string, object>(); dict.Add("A", "B"); _excelDataProvider.Stub(x => x.GetWorkbookNameValues()) .Return(dict); var nameValueProvider = new NameValueProvider(_excelDataProvider); var result = nameValueProvider.GetNamedValue("A"); Assert.AreEqual("B", result); dict.Clear(); nameValueProvider.Reload(); Assert.IsFalse(nameValueProvider.IsNamedValue("A")); }
public Token Create(IEnumerable <Token> tokens, string token) { Token tokenSeparator = null; if (_tokenSeparatorProvider.Tokens.TryGetValue(token, out tokenSeparator)) { return(tokenSeparator); } if (tokens.Any() && tokens.Last().TokenType == TokenType.String) { return(new Token(token, TokenType.StringContent)); } if (!string.IsNullOrEmpty(token)) { token = token.Trim(); } if (Regex.IsMatch(token, RegexConstants.Decimal)) { return(new Token(token, TokenType.Decimal)); } if (Regex.IsMatch(token, RegexConstants.Integer)) { return(new Token(token, TokenType.Integer)); } if (Regex.IsMatch(token, RegexConstants.Boolean, RegexOptions.IgnoreCase)) { return(new Token(token, TokenType.Boolean)); } if (Regex.IsMatch(token, RegexConstants.ExcelAddress)) { return(new Token(token, TokenType.ExcelAddress)); } if (_functionRepository.Exists(token)) { return(new Token(token, TokenType.Function)); } if (_nameValueProvider.IsNamedValue(token)) { return(new Token(token, TokenType.NameValue)); } return(new Token(token, TokenType.Unrecognized)); }