Skip to content

Commit

Permalink
Excised custom Contain and NotContain (by name) from DataTableCollect…
Browse files Browse the repository at this point in the history
…ionAssertionExtensions.cs and DataColumnCollectionAssertionExtensions.cs and the corresponding tests from DataTableCollectionAssertionExtensionsSpecs.cs and DataColumnCollectionAssertionExtensionsSpecs.cs.

Reran AcceptApiChanges.ps1.
Removed documentation for Contain and NotContain (by name) operations from data.md.
  • Loading branch information
logiclrd committed Feb 25, 2022
1 parent 9f55584 commit 2d54c82
Show file tree
Hide file tree
Showing 10 changed files with 0 additions and 388 deletions.
103 changes: 0 additions & 103 deletions Src/FluentAssertions/DataColumnCollectionAssertionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,108 +148,5 @@ public static class DataColumnCollectionAssertionExtensions

return new AndConstraint<GenericCollectionAssertions<DataColumn>>(assertion);
}

/// <summary>
/// Asserts that the current collection of <see cref="DataColumn"/>s contains a <see cref="DataColumn"/> with the
/// specified <paramref name="expectedColumnName"/> name.
/// </summary>
/// <param name="expectedColumnName">A name for a <see cref="DataColumn"/> that is expected to be in the
/// <see cref="DataColumnCollection"/>.</param>
/// <param name="because">
/// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
/// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
/// </param>
/// <param name="becauseArgs">
/// Zero or more objects to format using the placeholders in <paramref name="because" />.
/// </param>
public static AndConstraint<GenericCollectionAssertions<DataColumn>> ContainColumnWithName(
this GenericCollectionAssertions<DataColumn> assertion, string expectedColumnName, string because = "",
params object[] becauseArgs)
{
Guard.ThrowIfArgumentIsNull(
expectedColumnName, nameof(expectedColumnName), "Cannot verify that the collection contains a <null> DataColumn.");

if (assertion.Subject is null)
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:collection} to contain column named {0}{reason}, but found {1}.",
expectedColumnName, assertion.Subject);
}

bool containsColumn;

if (assertion.Subject is NonGenericCollectionWrapper<DataColumnCollection, DataColumn> wrapper)
{
containsColumn = wrapper.UnderlyingCollection.Contains(expectedColumnName);
}
else
{
containsColumn = assertion.Subject.Any(column => column.ColumnName == expectedColumnName);
}

if (!containsColumn)
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith(
"Expected {context:collection} to contain column named {0}{reason}, but it does not.",
expectedColumnName);
}

return new AndConstraint<GenericCollectionAssertions<DataColumn>>(assertion);
}

/// <summary>
/// Asserts that the current collection of <see cref="DataColumn"/>s does not contain a column with the the supplied
/// <paramref name="unexpectedColumnName" />.
/// </summary>
/// <param name="unexpectedColumnName">The column name that is not expected to be in the
/// <see cref="DataColumnCollection" /></param>
/// <param name="because">
/// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
/// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
/// </param>
/// <param name="becauseArgs">
/// Zero or more objects to format using the placeholders in <paramref name="because" />.
/// </param>
public static AndConstraint<GenericCollectionAssertions<DataColumn>> NotContainColumnWithName(
this GenericCollectionAssertions<DataColumn> assertion, string unexpectedColumnName, string because = "",
params object[] becauseArgs)
{
Guard.ThrowIfArgumentIsNull(
unexpectedColumnName, nameof(unexpectedColumnName),
"Cannot verify that the collection does not contain a <null> DataColumn.");

if (assertion.Subject is null)
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:collection} to not contain column named {0}{reason}, but found {1}.",
unexpectedColumnName, assertion.Subject);
}

bool containsColumn;

if (assertion.Subject is NonGenericCollectionWrapper<DataColumnCollection, DataColumn> wrapper)
{
containsColumn = wrapper.UnderlyingCollection.Contains(unexpectedColumnName);
}
else
{
containsColumn = assertion.Subject.Any(column => column.ColumnName == unexpectedColumnName);
}

if (containsColumn)
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith(
"Expected {context:collection} to not contain column named {0}{reason}, but it does.",
unexpectedColumnName);
}

return new AndConstraint<GenericCollectionAssertions<DataColumn>>(assertion);
}
}
}
104 changes: 0 additions & 104 deletions Src/FluentAssertions/DataTableCollectionAssertionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,109 +185,5 @@ public static class DataTableCollectionAssertionExtensions

return new AndConstraint<GenericCollectionAssertions<DataTable>>(assertion);
}

/// <summary>
/// Asserts that the current collection of <see cref="DataTable"/>s contains a <see cref="DataTable"/> with the specified
/// <paramref name="expectedTableName"/> name.
/// </summary>
/// <param name="expectedTableName">A name for a <see cref="DataTable"/> that is expected to be in the
/// <see cref="DataTableCollection"/>.</param>
/// <param name="because">
/// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
/// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
/// </param>
/// <param name="becauseArgs">
/// Zero or more objects to format using the placeholders in <paramref name="because" />.
/// </param>
public static AndConstraint<GenericCollectionAssertions<DataTable>> ContainTableWithName(
this GenericCollectionAssertions<DataTable> assertion, string expectedTableName, string because = "",
params object[] becauseArgs)
{
Guard.ThrowIfArgumentIsNull(
expectedTableName, nameof(expectedTableName), "Cannot verify that the collection contains a <null> DataTable.");

if (assertion.Subject is null)
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith(
"Expected {context:collection} to contain table named {0}{reason}, but found {1}.", expectedTableName,
assertion.Subject);
}

bool containsTable;

if (assertion.Subject is NonGenericCollectionWrapper<DataTableCollection, DataTable> wrapper)
{
containsTable = wrapper.UnderlyingCollection.Contains(expectedTableName);
}
else
{
containsTable = assertion.Subject.Any(table => table.TableName == expectedTableName);
}

if (!containsTable)
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith(
"Expected {context:collection} to contain table named {0}{reason}, but it does not.",
expectedTableName);
}

return new AndConstraint<GenericCollectionAssertions<DataTable>>(assertion);
}

/// <summary>
/// Asserts that the current collection of <see cref="DataTable"/>s does not contain a table with the the supplied
/// <paramref name="unexpectedTableName" />.
/// </summary>
/// <param name="unexpectedTableName">The table name that is not expected to be in the
/// <see cref="DataTableCollection"/></param>
/// <param name="because">
/// A formatted phrase as is supported by <see cref="string.Format(string,object[])" /> explaining why the assertion
/// is needed. If the phrase does not start with the word <i>because</i>, it is prepended automatically.
/// </param>
/// <param name="becauseArgs">
/// Zero or more objects to format using the placeholders in <paramref name="because" />.
/// </param>
public static AndConstraint<GenericCollectionAssertions<DataTable>> NotContainTableWithName(
this GenericCollectionAssertions<DataTable> assertion, string unexpectedTableName, string because = "",
params object[] becauseArgs)
{
Guard.ThrowIfArgumentIsNull(
unexpectedTableName, nameof(unexpectedTableName),
"Cannot verify that the collection does not contain a <null> DataTable.");

if (assertion.Subject is null)
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith("Expected {context:collection} to not contain table named {0}{reason}, but found {1}.",
unexpectedTableName, assertion.Subject);
}

bool containsTable;

if (assertion.Subject is NonGenericCollectionWrapper<DataTableCollection, DataTable> wrapper)
{
containsTable = wrapper.UnderlyingCollection.Contains(unexpectedTableName);
}
else
{
containsTable = assertion.Subject.Any(table => table.TableName == unexpectedTableName);
}

if (containsTable)
{
Execute.Assertion
.BecauseOf(because, becauseArgs)
.FailWith(
"Expected {context:collection} to not contain table named {0}{reason}, but it does.",
unexpectedTableName);
}

return new AndConstraint<GenericCollectionAssertions<DataTable>>(assertion);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,8 @@ namespace FluentAssertions
public static class DataColumnCollectionAssertionExtensions
{
public static FluentAssertions.AndConstraint<FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataColumn>> BeSameAs(this FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataColumn> assertion, System.Data.DataColumnCollection expected, string because = "", params object[] becauseArgs) { }
public static FluentAssertions.AndConstraint<FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataColumn>> ContainColumnWithName(this FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataColumn> assertion, string expectedColumnName, string because = "", params object[] becauseArgs) { }
public static FluentAssertions.AndConstraint<FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataColumn>> HaveSameCount(this FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataColumn> assertion, System.Data.DataColumnCollection otherCollection, string because = "", params object[] becauseArgs) { }
public static FluentAssertions.AndConstraint<FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataColumn>> NotBeSameAs(this FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataColumn> assertion, System.Data.DataColumnCollection unexpected, string because = "", params object[] becauseArgs) { }
public static FluentAssertions.AndConstraint<FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataColumn>> NotContainColumnWithName(this FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataColumn> assertion, string unexpectedColumnName, string because = "", params object[] becauseArgs) { }
public static FluentAssertions.AndConstraint<FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataColumn>> NotHaveSameCount(this FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataColumn> assertion, System.Data.DataColumnCollection otherCollection, string because = "", params object[] becauseArgs) { }
}
public static class DataRowAssertionExtensions
Expand Down Expand Up @@ -224,11 +222,9 @@ namespace FluentAssertions
public static class DataTableCollectionAssertionExtensions
{
public static FluentAssertions.AndConstraint<FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataTable>> BeSameAs(this FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataTable> assertion, System.Data.DataTableCollection expected, string because = "", params object[] becauseArgs) { }
public static FluentAssertions.AndConstraint<FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataTable>> ContainTableWithName(this FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataTable> assertion, string expectedTableName, string because = "", params object[] becauseArgs) { }
public static FluentAssertions.AndConstraint<FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataTable>> HaveSameCount(this FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataTable> assertion, System.Data.DataSet otherDataSet, string because = "", params object[] becauseArgs) { }
public static FluentAssertions.AndConstraint<FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataTable>> HaveSameCount(this FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataTable> assertion, System.Data.DataTableCollection otherCollection, string because = "", params object[] becauseArgs) { }
public static FluentAssertions.AndConstraint<FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataTable>> NotBeSameAs(this FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataTable> assertion, System.Data.DataTableCollection unexpected, string because = "", params object[] becauseArgs) { }
public static FluentAssertions.AndConstraint<FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataTable>> NotContainTableWithName(this FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataTable> assertion, string unexpectedTableName, string because = "", params object[] becauseArgs) { }
public static FluentAssertions.AndConstraint<FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataTable>> NotHaveSameCount(this FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataTable> assertion, System.Data.DataSet otherDataSet, string because = "", params object[] becauseArgs) { }
public static FluentAssertions.AndConstraint<FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataTable>> NotHaveSameCount(this FluentAssertions.Collections.GenericCollectionAssertions<System.Data.DataTable> assertion, System.Data.DataTableCollection otherCollection, string because = "", params object[] becauseArgs) { }
}
Expand Down
Loading

0 comments on commit 2d54c82

Please sign in to comment.