Skip to content

Commit

Permalink
Merge pull request #1814 from logiclrd/JDG_FillGapsInDataTesting
Browse files Browse the repository at this point in the history
  • Loading branch information
jnyrup committed Feb 21, 2022
2 parents a608990 + 5db93d5 commit 418a405
Show file tree
Hide file tree
Showing 12 changed files with 1,214 additions and 854 deletions.
6 changes: 3 additions & 3 deletions Src/FluentAssertions/Data/DataRowAssertions.cs
Expand Up @@ -43,13 +43,13 @@ public DataRowAssertions(TDataRow dataRow)
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:DataRow} to contain a column named '{0}'{reason}, but found <null>.", expectedColumnName);
.FailWith("Expected {context:DataRow} to contain a column named {0}{reason}, but found <null>.", expectedColumnName);
}
else if (!Subject.Table.Columns.Contains(expectedColumnName))
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:DataRow} to contain a column named '{0}'{reason}, but it does not.", expectedColumnName);
.FailWith("Expected {context:DataRow} to contain a column named {0}{reason}, but it does not.", expectedColumnName);
}
else
{
Expand Down Expand Up @@ -93,7 +93,7 @@ public AndConstraint<DataRowAssertions<TDataRow>> HaveColumns(IEnumerable<string
Execute.Assertion
.ForCondition(Subject.Table.Columns.Contains(expectedColumnName))
.BecauseOf(because, becauseArgs)
.FailWith("Expected table containing {context:DataRow} to contain a column named '{0}'{reason}, but it does not.", expectedColumnName);
.FailWith("Expected table containing {context:DataRow} to contain a column named {0}{reason}, but it does not.", expectedColumnName);
}

return new AndConstraint<DataRowAssertions<TDataRow>>(this);
Expand Down
6 changes: 3 additions & 3 deletions Src/FluentAssertions/Data/DataSetAssertions.cs
Expand Up @@ -73,13 +73,13 @@ public AndConstraint<DataSetAssertions<TDataSet>> HaveTableCount(int expected, s
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:DataSet} to contain a table named '{0}'{reason}, but found <null>.", expectedTableName);
.FailWith("Expected {context:DataSet} to contain a table named {0}{reason}, but found <null>.", expectedTableName);
}
else if (!Subject.Tables.Contains(expectedTableName))
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:DataSet} to contain a table named '{0}'{reason}, but it does not.", expectedTableName);
.FailWith("Expected {context:DataSet} to contain a table named {0}{reason}, but it does not.", expectedTableName);
}
else
{
Expand Down Expand Up @@ -123,7 +123,7 @@ public AndConstraint<DataSetAssertions<TDataSet>> HaveTables(IEnumerable<string>
Execute.Assertion
.ForCondition(Subject.Tables.Contains(expectedTableName))
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:DataSet} to contain a table named '{0}'{reason}, but it does not.", expectedTableName);
.FailWith("Expected {context:DataSet} to contain a table named {0}{reason}, but it does not.", expectedTableName);
}

return new AndConstraint<DataSetAssertions<TDataSet>>(this);
Expand Down
6 changes: 3 additions & 3 deletions Src/FluentAssertions/Data/DataTableAssertions.cs
Expand Up @@ -73,13 +73,13 @@ public AndConstraint<DataTableAssertions<TDataTable>> HaveRowCount(int expected,
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:DataTable} to contain a column named '{0}'{reason}, but found <null>.", expectedColumnName);
.FailWith("Expected {context:DataTable} to contain a column named {0}{reason}, but found <null>.", expectedColumnName);
}
else if (!Subject.Columns.Contains(expectedColumnName))
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:DataTable} to contain a column named '{0}'{reason}, but it does not.", expectedColumnName);
.FailWith("Expected {context:DataTable} to contain a column named {0}{reason}, but it does not.", expectedColumnName);
}
else
{
Expand Down Expand Up @@ -123,7 +123,7 @@ public AndConstraint<DataTableAssertions<TDataTable>> HaveColumns(IEnumerable<st
Execute.Assertion
.ForCondition(Subject.Columns.Contains(expectedColumnName))
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:DataTable} to contain a column named '{0}'{reason}, but it does not.", expectedColumnName);
.FailWith("Expected {context:DataTable} to contain a column named {0}{reason}, but it does not.", expectedColumnName);
}

return new AndConstraint<DataTableAssertions<TDataTable>>(this);
Expand Down
Expand Up @@ -59,15 +59,15 @@ protected override EquivalencyResult OnHandle(Comparands comparands, IEquivalenc
{
AssertionScope.Current
.ForCondition(subject.RelationName == expectation.RelationName)
.FailWith("Expected {context:DataRelation} to have RelationName of '{0}'{reason}, but found '{1}'",
.FailWith("Expected {context:DataRelation} to have RelationName of {0}{reason}, but found {1}",
expectation.RelationName, subject.RelationName);
}

if (selectedMembers.ContainsKey(nameof(expectation.Nested)))
{
AssertionScope.Current
.ForCondition(subject.Nested == expectation.Nested)
.FailWith("Expected {context:DataRelation} to have Nested value of '{0}'{reason}, but found '{1}'",
.FailWith("Expected {context:DataRelation} to have Nested value of {0}{reason}, but found {1}",
expectation.Nested, subject.Nested);
}

Expand Down
Expand Up @@ -99,7 +99,7 @@ private static Type[] GatherPrimaryKeyColumnTypes(DataTable table, string compar
if ((table.PrimaryKey is null) || (table.PrimaryKey.Length == 0))
{
AssertionScope.Current
.FailWith("Table '{0}' containing {1} {context:DataRowCollection} does not have a primary key. RowMatchMode.PrimaryKey cannot be applied.", table.TableName, comparisonTerm);
.FailWith("Table {0} containing {1} {context:DataRowCollection} does not have a primary key. RowMatchMode.PrimaryKey cannot be applied.", table.TableName, comparisonTerm);
}
else
{
Expand Down
14 changes: 7 additions & 7 deletions Src/FluentAssertions/Equivalency/Steps/DataRowEquivalencyStep.cs
Expand Up @@ -50,7 +50,7 @@ protected override EquivalencyResult OnHandle(Comparands comparands, IEquivalenc
{
AssertionScope.Current
.ForCondition(subject.GetType() == expectation.GetType())
.FailWith("Expected {context:DataRow} to be of type '{0}'{reason}, but found '{1}'",
.FailWith("Expected {context:DataRow} to be of type {0}{reason}, but found {1}",
expectation.GetType(), subject.GetType());
}

Expand All @@ -74,15 +74,15 @@ private static void CompareScalarProperties(DataRow subject, DataRow expectation
{
AssertionScope.Current
.ForCondition(subject.HasErrors == expectation.HasErrors)
.FailWith("Expected {context:DataRow} to have HasErrors value of '{0}'{reason}, but found '{1}' instead",
.FailWith("Expected {context:DataRow} to have HasErrors value of {0}{reason}, but found {1} instead",
expectation.HasErrors, subject.HasErrors);
}

if (selectedMembers.RowState)
{
AssertionScope.Current
.ForCondition(subject.RowState == expectation.RowState)
.FailWith("Expected {context:DataRow} to have RowState value of '{0}'{reason}, but found '{1}' instead",
.FailWith("Expected {context:DataRow} to have RowState value of {0}{reason}, but found {1} instead",
expectation.RowState, subject.RowState);
}
}
Expand All @@ -91,10 +91,10 @@ private static void CompareScalarProperties(DataRow subject, DataRow expectation
DataRow subject, DataRow expectation, DataEquivalencyAssertionOptions<DataSet> dataSetConfig,
DataEquivalencyAssertionOptions<DataTable> dataTableConfig, DataEquivalencyAssertionOptions<DataRow> dataRowConfig)
{
IEnumerable<string> expectationColumnNames = expectation.Table.Columns.OfType<DataColumn>()
IEnumerable<string> expectationColumnNames = expectation.Table.Columns.Cast<DataColumn>()
.Select(col => col.ColumnName);

IEnumerable<string> subjectColumnNames = subject.Table.Columns.OfType<DataColumn>()
IEnumerable<string> subjectColumnNames = subject.Table.Columns.Cast<DataColumn>()
.Select(col => col.ColumnName);

bool ignoreUnmatchedColumns =
Expand Down Expand Up @@ -139,11 +139,11 @@ private static void CompareScalarProperties(DataRow subject, DataRow expectation
{
AssertionScope.Current
.ForCondition(subjectColumn is not null)
.FailWith("Expected {context:DataRow} to have column '{0}'{reason}, but found none", columnName);
.FailWith("Expected {context:DataRow} to have column {0}{reason}, but found none", columnName);

AssertionScope.Current
.ForCondition(expectationColumn is not null)
.FailWith("Found unexpected column '{0}' in {context:DataRow}", columnName);
.FailWith("Found unexpected column {0} in {context:DataRow}", columnName);
}

if ((subjectColumn is not null) && (expectationColumn is not null))
Expand Down
28 changes: 14 additions & 14 deletions Src/FluentAssertions/Equivalency/Steps/DataSetEquivalencyStep.cs
Expand Up @@ -41,7 +41,7 @@ protected override EquivalencyResult OnHandle(Comparands comparands, IEquivalenc
{
AssertionScope.Current
.ForCondition(subject.GetType() == expectation.GetType())
.FailWith("Expected {context:DataSet} to be of type '{0}'{reason}, but found '{1}'", expectation.GetType(), subject.GetType());
.FailWith("Expected {context:DataSet} to be of type {0}{reason}, but found {1}", expectation.GetType(), subject.GetType());
}

var selectedMembers = GetMembersFromExpectation(comparands, context.CurrentNode, context.Options)
Expand All @@ -64,63 +64,63 @@ private static void CompareScalarProperties(DataSet subject, DataSet expectation
{
AssertionScope.Current
.ForCondition(subject.DataSetName == expectation.DataSetName)
.FailWith("Expected {context:DataSet} to have DataSetName '{0}'{reason}, but found '{1}' instead", expectation.DataSetName, subject.DataSetName);
.FailWith("Expected {context:DataSet} to have DataSetName {0}{reason}, but found {1} instead", expectation.DataSetName, subject.DataSetName);
}

if (selectedMembers.ContainsKey(nameof(expectation.CaseSensitive)))
{
AssertionScope.Current
.ForCondition(subject.CaseSensitive == expectation.CaseSensitive)
.FailWith("Expected {context:DataSet} to have CaseSensitive value of '{0}'{reason}, but found '{1}' instead", expectation.CaseSensitive, subject.CaseSensitive);
.FailWith("Expected {context:DataSet} to have CaseSensitive value of {0}{reason}, but found {1} instead", expectation.CaseSensitive, subject.CaseSensitive);
}

if (selectedMembers.ContainsKey(nameof(expectation.EnforceConstraints)))
{
AssertionScope.Current
.ForCondition(subject.EnforceConstraints == expectation.EnforceConstraints)
.FailWith("Expected {context:DataSet} to have EnforceConstraints value of '{0}'{reason}, but found '{1}' instead", expectation.EnforceConstraints, subject.EnforceConstraints);
.FailWith("Expected {context:DataSet} to have EnforceConstraints value of {0}{reason}, but found {1} instead", expectation.EnforceConstraints, subject.EnforceConstraints);
}

if (selectedMembers.ContainsKey(nameof(expectation.HasErrors)))
{
AssertionScope.Current
.ForCondition(subject.HasErrors == expectation.HasErrors)
.FailWith("Expected {context:DataSet} to have HasErrors value of '{0}'{reason}, but found '{1}' instead", expectation.HasErrors, subject.HasErrors);
.FailWith("Expected {context:DataSet} to have HasErrors value of {0}{reason}, but found {1} instead", expectation.HasErrors, subject.HasErrors);
}

if (selectedMembers.ContainsKey(nameof(expectation.Locale)))
{
AssertionScope.Current
.ForCondition(subject.Locale == expectation.Locale)
.FailWith("Expected {context:DataSet} to have Locale value of '{0}'{reason}, but found '{1}' instead", expectation.Locale, subject.Locale);
.FailWith("Expected {context:DataSet} to have Locale value of {0}{reason}, but found {1} instead", expectation.Locale, subject.Locale);
}

if (selectedMembers.ContainsKey(nameof(expectation.Namespace)))
{
AssertionScope.Current
.ForCondition(subject.Namespace == expectation.Namespace)
.FailWith("Expected {context:DataSet} to have Namespace value of '{0}'{reason}, but found '{1}' instead", expectation.Namespace, subject.Namespace);
.FailWith("Expected {context:DataSet} to have Namespace value of {0}{reason}, but found {1} instead", expectation.Namespace, subject.Namespace);
}

if (selectedMembers.ContainsKey(nameof(expectation.Prefix)))
{
AssertionScope.Current
.ForCondition(subject.Prefix == expectation.Prefix)
.FailWith("Expected {context:DataSet} to have Prefix value of '{0}'{reason}, but found '{1}' instead", expectation.Prefix, subject.Prefix);
.FailWith("Expected {context:DataSet} to have Prefix value of {0}{reason}, but found {1} instead", expectation.Prefix, subject.Prefix);
}

if (selectedMembers.ContainsKey(nameof(expectation.RemotingFormat)))
{
AssertionScope.Current
.ForCondition(subject.RemotingFormat == expectation.RemotingFormat)
.FailWith("Expected {context:DataSet} to have RemotingFormat value of '{0}'{reason}, but found '{1}' instead", expectation.RemotingFormat, subject.RemotingFormat);
.FailWith("Expected {context:DataSet} to have RemotingFormat value of {0}{reason}, but found {1} instead", expectation.RemotingFormat, subject.RemotingFormat);
}

if (selectedMembers.ContainsKey(nameof(expectation.SchemaSerializationMode)))
{
AssertionScope.Current
.ForCondition(subject.SchemaSerializationMode == expectation.SchemaSerializationMode)
.FailWith("Expected {context:DataSet} to have SchemaSerializationMode value of '{0}'{reason}, but found '{1}' instead", expectation.SchemaSerializationMode, subject.SchemaSerializationMode);
.FailWith("Expected {context:DataSet} to have SchemaSerializationMode value of {0}{reason}, but found {1} instead", expectation.SchemaSerializationMode, subject.SchemaSerializationMode);
}
}

Expand Down Expand Up @@ -185,9 +185,9 @@ private static void CompareTables(IEquivalencyValidationContext context, IEquiva
}
}

IEnumerable<string> expectationTableNames = expectation.Tables.OfType<DataTable>()
IEnumerable<string> expectationTableNames = expectation.Tables.Cast<DataTable>()
.Select(table => table.TableName);
IEnumerable<string> subjectTableNames = subject.Tables.OfType<DataTable>()
IEnumerable<string> subjectTableNames = subject.Tables.Cast<DataTable>()
.Select(table => table.TableName);

foreach (string tableName in expectationTableNames.Union(subjectTableNames))
Expand All @@ -210,10 +210,10 @@ private static void CompareTables(IEquivalencyValidationContext context, IEquiva

bool success = AssertionScope.Current
.ForCondition(subjectTable is not null)
.FailWith("Expected {context:DataSet} to contain table '{0}'{reason}, but did not find it", tableName)
.FailWith("Expected {context:DataSet} to contain table {0}{reason}, but did not find it", tableName)
.Then
.ForCondition(expectationTable is not null)
.FailWith("Found unexpected table '{0}' in DataSet", tableName);
.FailWith("Found unexpected table {0} in DataSet", tableName);

if (success)
{
Expand Down

0 comments on commit 418a405

Please sign in to comment.