New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restore basic assertions for collections in System.Data
#1812
Restore basic assertions for collections in System.Data
#1812
Commits on Apr 15, 2022
-
Updated AssertionExtensions.cs with overloads to pass calls to .Shoul…
…d() on DataTableCollection, DataColumnCollection and DataRowCollection into GenericCollectionAssertions using LINQ's .Cast<T>() method. Added type DataTableCollectionAssertionExtensions.cs with assertions specific to DataTableCollection as extensions on GenericCollectionAssertions<DataTable>. Added type DataColumnCollectionAssertionExtensions.cs with assertions specific to DataColumnCollection as extensions on GenericCollectionAssertions<DataColumn>. Added type DataRowCollectionAssertionExtensions.cs with assertions specific to DataRowCollection as extensions on GenericCollectionAssertions<DataRow>. Reran AcceptApiChanges.ps1 to update the approved API surface. Added automated tests of DataTableCollectionAssertionExtensions in new class Collections/Data/DataTableCollectionAssertionExtensionsSpecs.cs in FluentAssertions.Specs. Added automated tests of DataColumnCollectionAssertionExtensions in new class Collections/Data/DataColumnCollectionAssertionExtesnionsSpecs.cs in FluentAssertions.Specs. Added automated tests of DataRowCollectionAssertionExtensions in new class Collections/Data/DataRowCollectionAssertionExtensionsSpecs.cs in FluentAssertions.Specs. Added documentation of the new methods to docs/_pages/data.md. Added a corresponding line to the release notes in docs/_pages/releases.md.
-
Added type NonGenericCollectionWrapper.cs in FluentAssertions/Common.…
… This ensures that the Count property is passed through to the underlying implementation, and also allows code that knows about it to directly access the wrapped collection object. Updated AssertionExtensions.c to use NonGenericCollectionWrapper instead of System.Linq's .Cast<TItem> to produce the generic collections for use with GenericCollectionAssertions<TItem> in Should overloads for DataTableCollection, DataColumnCollection and DataRowCollection. Updated the ContainTableWithName methods in DataTableCollectionAssertionExtensions.cs and ContainColumnWithName in DataColumnCollectionAssertionExtensions.cs to check if the assertion subject is a NonGenericCollectionWrapper and, if so, use it to gain access to the underlying Contains functionality rather than requiring the collection to be enumerated.
-
Corrected a copy/paste error in the XML docs in DataRowCollectionAsse…
…rtionExtensions.cs. Added BeSameAs and NotBeSameAs extension methods in DataTableCollectionAssertionExtensions, DataColumnCollectionAssertionExtensions and DataRowCollectionAssertionExtensions, since the default ReferenceTypeAssertions implementation is broken by the NonGenericCollectionWrapper wrapping. Added automated tests of the new functionality. Reran AcceptApiChanges.ps1.
-
- Improved the wording of XML documentation of .Should() for DataTableCollection, DataColumnCollection and DataRowCollection. - Moved DataTableCollectionAssertionExtensions.cs, DataColumnCollectionAssertionExtensions.cs and DataRowCollectionAssertionExtensions.cs to the project root.
-
Rewrote HaveSameCount and NotHaveSameCount in DataTableCollectionAsse…
…rtionExtensions.cs, DataColumnCollectionAssertionExtensions.cs and DataRowCollectionAssertionExtensions.cs to use fluent assertion execution syntax. Updated automatde tests correspondingly, ensuring coverage.
-
Generalized the implementations of HaveSameCount and NotHaveSameCount…
… in DataTableCollectionAssertionExtensions.cs, DataColumncollectionAssertionExtensions.cs and DataRowCollectionAssertionExtensions.cs to operate on ICollection<T> instead of NonGenericCollectionWrapper<TCollection, T> specifically.
-
Simplified the implementation of HaveSameCount and NotHaveSameCount i…
…n DataTableCollectionAssertionExtensions.cs, DataColumnCollectionAssertionExtensions.cs and DataRowCollectionAssertionExtensions.cs, following the observation that IEnumerable<T>.Count() in LINQ actually already contains logic to pass the call through to ICollection<T>.Count if the subject implements that interface. Since NonGenericCollectionWrapper<TCollection, T> implements this interface, this meets our needs in avoiding having the underlying collection be enumerated. Updated tests correspondingly, removing checks for a subtle semaphore that was used to allow the tests to verify which branch in the HaveSameCount / NotHaveSameCount implementation had been taken. This is no longer needed and is no longer present.
-
PR feedback related to DataTableCollectionAssertionExtensions.cs, Dat…
…aColumnCollectionAssertionExtensions.cs and DataRowCollectionAssertions.cs: - Renamed expected to expectation in several places. Reran AcceptApiChanges.ps1. - Updated calls to FailWith to directly specify collection identifier instead of using WithDefaultIdentifier. - Improved XML documentation for assertions. - Added assertions on the null ugard in BeSubsetOf and NotBeSubsetOf for DataRowCollectionAssertions.cs.
-
Restructured assertions in DataTableCollectionAssertionExtensionsSpec…
…s.cs, DataColumnCollectionAssertionExtensionsSpecs.cs and DataRowCollectionAssertionExtensionsSpecs.cs to use nested subclasses, and substantially simplified all of the test method names since they are in different namespaces now.
-
Updated all System.Data collection specs to ensure that the exception…
… that was thrown is actually the expected error. Updated a few .FailWith calls to include additional wording to make the message clearer. Added guards to BeSubsetOf and NotBeSubsetOf overloads in DataRowCollectionAssertionExtension.cs that then proceed to call a LINQ method on the supplied expectation.
-
Eliminated explicit type names from test names in DataTableCollection…
…AssertionExtensionsSpecs.cs, DataColumnCollectionAssertionExtensionSpecs.cs and DataRowCollectionAssertionExtensionsSpecs.cs with judicious use of nested classes.
-
Reverted partial renaming of "expected" to "expectation".
Reran AcceptApiChanges.ps1.
-
Updated BeSameAs assertions in DataTableCollectionAssertionExtensions…
….cs, DataColumnCollectionAssertionExtensions.cs and DataRowCollectionAssertionExtensions.cs to provide different failure messages for different paths. Corrected a format string error in the generic collection path ("{1}" when there was only one formatting argument). Added tests to DataTableCollectionAssertionExtensionsSpecs.cs, DataColumnCollectionAssertionExtensionsSpecs.cs and DataRowCollectionAssertionExtensionsSpecs.cs to verify that the path for subjects that aren't System.Data collections is in fact needed & gets hit.
-
- Corrected a typo "Expeected" in DataTableCollectionAssertionExtensions.cs and DataColumnAssertionExtensions.cs. - Updated the construction of NonGenericCollectionWrapper to use a helper method that returns null instead of wrapping null. Added a helper method for each System.Data type to NonGenericCollectionWrapper.cs.
-
Added a null argument guard to the constructor of NonGenericCollectio…
…nWrapper<TCollection, TItem>.
-
Excised set operations from DataRowCollectionAssertionExtensions.cs a…
…nd the corresponding tests from DataRowCollectionAssertionExtensionsSpecs.cs. Reran AcceptApiChanges.ps1.
-
-
Removed ContainEquivalentOf and NotContainEquivalentOf from DataRowCo…
…llectionAssertionExtensions.cs, as their implementation is actually identical to that in GenericCollectionAssertions. Reran AcceptApiChanges.ps1. Added tests to DataRowCollectionAssertionExtensionsSpecs.cs to verify that ContainEquivalentOf and NotContainEquivalentOf do the right thing with DataRow objects & collections.
-
Corrected assertion failure messages for BeSameAs in DataTableCollect…
…ionAssertionExtensions.cs, DataColumnCollectionAssertionExtensions.cs and DataRowCollectionAssertionExtensions.cs. Removed unnecessary calls to .ForCondition(false). Removed unnecessary cast from IEnumerable<DataRow> to IEnumerable<object> in ContainEquivalentOf in DataRowCollectionAssertionExtensions.cs. Updated ContainEquivalentOf in DataRowCollectionAssertions.cs to return an AndWhichConstraint.
-
Excised custom Contain and NotContain (by name) from DataTableCollect…
…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.
-
Added tests that cover the situation where the subject is null to Dat…
…aTableCollectionAssertionExtensionsSpecs.cs, DataColumnCollectionAssertionExtensionsSpecs.cs and DataRowCollectionAssertionExtensionSpecs.cs. Corrected indentation error in DataRowCollectionAssertionExtensions.cs.
-
Unrolled loops in DataTableCollectionAssertionExtensionsSpecs.cs, Dat…
…aColumnCollectionAssertionExtensionsSpecs.cs and DataRowCollectionAssertionExtensionsSpecs.cs.
-
Simplified tests in DataTableCollectionAssertionExtensionsSpecs.cs an…
…d DataColumnCollectionAssertionExtensionsSpecs.cs. Since the tests don't actually look at the column specifications, it isn't important that they be assigned a variety of different types.
-
Removed some additional unnecessary test subject set-up from DataRowC…
…ollectionAssertionExtensionsSpecs.cs.
-
Eliminated helper functions in the construction of subject and expect…
…ation DataTables in DataTableCollectionAssertionExtensionsSpecs.cs and DataRowCollectionAssertionExtensionsSpecs.cs.
-
Added additional tests to DataTableCollectionAssertionExtensionsSpecs…
….cs so that the DataSet overloads are covered.
-
- Removed unnecessary references to IEnumerable and IEnumerable<T>, already covered by implementing/constraining against ICollection and ICollection<T>. - Made UnderlyingCollection in ReadOnlyNonGenericCollectionWrapper<T> immutable.
-
Renamed DataTableCollectionAssertionExtensionsSpecs.cs to DataTableCo…
…llectionAssertionSpecs.cs. Renamed DataColumnCollectionAssertionExtensionsSpecs.cs to DataColumnCollectionAssertionSpecs.cs. Renamed DataRowCollectionAssertionExtensionsSpecs.cs to DataRowCollectionAssertionSpecs.cs.
-
Added utility class TypeDescriptionUtility.cs, along with unit tests …
…in TypeDescriptionUtilitySpecs.cs. Refactored AssertionScope.FailWith to produce new utility method AssertionScope.FormatFailureMessage. Updated DataTableCollectionAssertionExtensions.cs, DataColumnCollectionAssertionExtensions.cs and DataRowCollectionAssertionExtensions.cs to throw InvalidOperationException when BeSameAs or NotBeSameAs is called with a subject of the wrong type, using the new AssertionScope.FormatFailureMessage method to give the exception an appropriate message. Updated DataTableCollectionAssertionSpecs.cs, DataColumnCollectionAssertionSpecs.cs and DataRowCollectionAssertionSpecs.cs to account for the change in the exception type & message in the When_generic_collection_is_tested_against_typed_collection_it_should_fail test methods.
-
Changed direct InvalidOperationException in BeSameAs and NotBeSameAs …
…in DataTableCollectionAssertionExtensions.cs, DataColumnCollectionAssertionExtensions.cs and DataRowCollectionAssertionExtensions.cs into a standard assertion flow. Updated unit tests correspondingly.
-
Undid the refactoring of FailWith in AssertionScope.cs that produced …
…an internal method FormatFailureMessage to allow reuse.
-
Made TypeDescriptionUtility.GetTypeDescription non-discoverable, as n…
…othing _currently_ has a need to get a description for a Type directly.
-
Moved TypeDescriptionUtility to the Common folder/namespace. Updated …
…the TypeDescriptionUtilitySpecs.cs class correspondingly. All actual uses of TypeDescriptionUtility already import this namespace so no other changes are needed.
-