public override bool Matches(object actual) { if (actual is IDbCommand) { return(Process((IDbCommand)actual)); } else if (actual is FormattedResults) { this.actual = actual; var res = true; foreach (var result in (FormattedResults)actual) { var ctr = BuildInternalConstraint(); if (!DoMatch(ctr, result)) { res = false; invalidMembers.Add(result); } } return(res); } else { throw new ArgumentException(); } }
public void Matches_RegexWronglySpecified_Validated() { var cells = new FormattedResults(); cells.Add("$185,125.12"); cells.Add("$125.12"); cells.Add("$125"); var matchPatternConstraint = new MatchPatternConstraint(); matchPatternConstraint = matchPatternConstraint.Regex(@"^\$?[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}$"); //Method under test var res = matchPatternConstraint.Matches(cells); //Test conclusion Assert.That(res, Is.False); }
public void Matches_RegexCorrectlySpecified_Validated() { var cells = new FormattedResults(); cells.Add("$185,125.12"); cells.Add("$125.12"); cells.Add("$125.00"); var matchPatternConstraint = new MatchPatternConstraint(); matchPatternConstraint = matchPatternConstraint.Regex(@"^\$?[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}$"); //Method under test var res = matchPatternConstraint.Matches(cells); //Test conclusion Assert.That(res, Is.True); }
public FormattedResults GetFormats() { var cellSet = ExecuteCellSet(); var formattedResults = new FormattedResults(); foreach (var cell in cellSet.Cells) { formattedResults.Add(cell.FormattedValue); } return(formattedResults); }
public void WriteDescription_OneItemHasFailed_CorrectKeywordsForPredicate() { var cells = new FormattedResults(); cells.Add("$185,125.12"); cells.Add("$125.12"); cells.Add("$125"); var matchPatternConstraint = new MatchPatternConstraint(); matchPatternConstraint = matchPatternConstraint.Regex(@"^\$?[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}$"); //Method under test var res = matchPatternConstraint.Matches(cells); var msg = new MessageWriter(); matchPatternConstraint.WriteDescriptionTo(msg); //Test conclusion Assert.That(msg.Predicate, Is.StringContaining("cell") .And.StringContaining("regex")); }
public void WriteDescription_OneItemHasFailed_CorrectKeywordsForActualValue() { var cells = new FormattedResults(); cells.Add("$185,125.12"); cells.Add("$125.12"); cells.Add("$125"); var matchPatternConstraint = new MatchPatternConstraint(); matchPatternConstraint = matchPatternConstraint.Regex(@"^\$?[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}$"); //Method under test var res = matchPatternConstraint.Matches(cells); var msg = new MessageWriter(); matchPatternConstraint.WriteActualValueTo(msg); //Test conclusion Assert.That(msg.Message, Is.StringContaining("$125") .And.StringContaining("doesn't validate this pattern")); }
public FormattedResults GetFormats() { var dataSet = Execute(); var formattedResults = new FormattedResults(); foreach (DataRow row in dataSet.Tables[0].Rows) { foreach (var item in row.ItemArray) { formattedResults.Add(item.ToString()); } } return(formattedResults); }
public FormattedResults GetFormats() { var cellSet = ExecuteCellSet(); var formattedResults = new FormattedResults(); foreach (var cell in cellSet.Cells) { formattedResults.Add(cell.FormattedValue); } return formattedResults; }
public FormattedResults GetFormats() { var dataSet = Execute(); var formattedResults = new FormattedResults(); foreach (DataRow row in dataSet.Tables[0].Rows) { foreach (var item in row.ItemArray) formattedResults.Add(item.ToString()); } return formattedResults; }