Skip to content

Commit

Permalink
Update package references, refactor code, and fix namespace
Browse files Browse the repository at this point in the history
Updated the package references in the csproj files. Refactored the code in several files to improve readability and maintainability. Also, fixed the namespace in the DataTableAssertionExtensions and DataRowAssertionExtensions classes to align with standard conventions. No functional changes were made.
  • Loading branch information
dennisdoomen committed Nov 10, 2023
1 parent b464027 commit eca2d43
Show file tree
Hide file tree
Showing 29 changed files with 69 additions and 92 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
root = true
root = true
# EditorConfig is awesome: http://EditorConfig.org

# top-most EditorConfig file
Expand Down Expand Up @@ -172,7 +172,7 @@ dotnet_diagnostic.RS0030.severity = error
dotnet_diagnostic.IDE0004.severity = error

# IDE0005: Remove unnecessary usings/imports
dotnet_diagnostic.IDE0005.severity = suggestion
dotnet_diagnostic.IDE0005.severity = error

# IDE0051: Remove unused private members (no reads or writes)
dotnet_diagnostic.IDE0051.severity = error
Expand Down
4 changes: 2 additions & 2 deletions Build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<PackageDownload Include="xunit.runner.console" Version="[2.5.0]" />
<PackageDownload Include="Node.js.redist" Version="[16.20.0]" />
<PackageReference Include="LibGit2Sharp" Version="0.27.2" />
<PackageReference Include="Nuke.Common" Version="7.0.4" />
<PackageReference Include="Nuke.Components" Version="7.0.4" />
<PackageReference Include="Nuke.Common" Version="7.0.6" />
<PackageReference Include="Nuke.Components" Version="7.0.6" />
<PackageDownload Include="Yarn.MSBuild" Version="[1.22.19]" />
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisLevel>7.0</AnalysisLevel>
<AnalysisMode>All</AnalysisMode>
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>
Expand All @@ -26,15 +26,15 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CSharpGuidelinesAnalyzer" Version="3.8.3">
<PackageReference Include="CSharpGuidelinesAnalyzer" Version="3.8.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.Analyzers" Version="4.3.0">
<PackageReference Include="Roslynator.Analyzers" Version="4.6.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Meziantou.Analyzer" Version="2.0.70">
<PackageReference Include="Meziantou.Analyzer" Version="2.0.103">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
[![Coveralls branch](https://img.shields.io/coverallsCoverage/github/fluentassertions/fluentassertions.datasets?branch=develop)](https://coveralls.io/github/fluentassertions/fluentassertions.datasets?branch=develop)
[![](https://img.shields.io/github/release/FluentAssertions.Datasets/FluentAssertions.Datasets.svg?label=latest%20release&color=007edf)](https://github.com/FluentAssertions/FluentAssertions.DataSets/releases/latest)
[![](https://img.shields.io/nuget/dt/FluentAssertions.DataSets.svg?label=downloads&color=007edf&logo=nuget)](https://www.nuget.org/packages/FluentAssertions.DataSets)
[![](https://img.shields.io/librariesio/dependents/nuget/FluentAssertions.DataSets.svg?label=dependent%20libraries)](https://libraries.io/nuget/FluentAssertions.Data)
[![](https://img.shields.io/librariesio/dependents/nuget/FluentAssertions.DataSets.svg?label=dependent%20libraries)](https://libraries.io/nuget/FluentAssertions.DataSets)
[![GitHub Repo stars](https://img.shields.io/github/stars/fluentassertions/fluentassertions.datasets)](https://github.com/fluentassertions/fluentassertions.datasets/stargazers)
[![GitHub contributors](https://img.shields.io/github/contributors/fluentassertions/fluentassertions.datasets)](https://github.com/fluentassertions/fluentassertions.datasets/graphs/contributors)
[![GitHub last commit](https://img.shields.io/github/last-commit/fluentassertions/fluentassertions.datasets)](https://github.com/fluentassertions/fluentassertions.data)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/fluentassertions/fluentassertions.data)](https://github.com/fluentassertions/fluentassertions.data/graphs/commit-activity)
[![open issues](https://img.shields.io/github/issues/fluentassertions/fluentassertions.data)](https://github.com/fluentassertions/fluentassertions.data/issues)
[![GitHub last commit](https://img.shields.io/github/last-commit/fluentassertions/fluentassertions.datasets)](https://github.com/fluentassertions/fluentassertions.datasets)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/fluentassertions/fluentassertions.datasets)](https://github.com/fluentassertions/fluentassertions.data/graphs/commit-activity)
[![open issues](https://img.shields.io/github/issues/fluentassertions/fluentassertions.datasets)](https://github.com/fluentassertions/fluentassertions.datasets/issues)
![](https://img.shields.io/badge/release%20strategy-githubflow-orange.svg)

Extends https://www.fluentassertions.com with specialized assertions for dealing with `DataSet`, `DataTable`, `DataRow` and `DataColumn`

> [!WARNING]
> This set of extensions was extracted from Fluent Assertions 6 and is in maintenance mode. Pull Requests will still be accepted, but we will not actively work on improvements or bugs.
> This set of extensions was extracted from Fluent Assertions 6 and is in maintenance mode. Pull Requests will still be accepted, but we will not actively work on improvements or bugs.
# Information
* Uses [Semantic Versioning](https://semver.org/lang/nl/)
Expand All @@ -24,7 +24,7 @@ Extends https://www.fluentassertions.com with specialized assertions for dealing

# Installation

This package is shipped as a [NuGet package](https://www.nuget.org/packages/FluentAssertions.Data) and can be installed through the CLI using:
This package is shipped as a [NuGet package](https://www.nuget.org/packages/FluentAssertions.DataSets) and can be installed through the CLI using:

dotnet add package FluentAssertions.DataSets

Expand All @@ -33,8 +33,8 @@ This package is shipped as a [NuGet package](https://www.nuget.org/packages/Flue
## Prerequisites

* Visual Studio 2022 or JetBrains Rider 2021.3
* Build Tools 2022 (including the Universal Windows Platform build tools).
* .NET Framework 4.7 SDK
* Build Tools 2022 (including the Universal Windows Platform build tools).
* .NET Framework 4.7 SDK
* .NET 7.0 SDK installed. Check the `global.json`` for the current minimum required version.

## Building
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Collections.Generic;
using System.Data;
using System.Linq;
using FluentAssertions.Common;

namespace FluentAssertions.DataSets.Common;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Data;
using System.Linq;
using FluentAssertions.Collections;
using FluentAssertions.Common;
using FluentAssertions.DataSets.Common;
using FluentAssertions.Execution;

Expand Down
13 changes: 3 additions & 10 deletions Src/FluentAssertions.DataSets/DataEquivalencyAssertionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Data;
using System.Linq.Expressions;
using System.Reflection;
using FluentAssertions.DataSets.Equivalency;
using FluentAssertions.Equivalency;

namespace FluentAssertions.DataSets;
Expand Down Expand Up @@ -127,8 +126,7 @@ private void ExcludeMemberOfSubtypeOfRelatedTypeByGeneratedPredicate<TDeclaringT

private static MemberInfo GetMemberAccessTargetMember(Expression expression)
{
if (expression is UnaryExpression unaryExpression
&& unaryExpression.NodeType == ExpressionType.Convert)
if (expression is UnaryExpression { NodeType: ExpressionType.Convert } unaryExpression)
{
// If the expression is a value type, then accessing it will involve an
// implicit boxing conversion to type object that we need to ignore.
Expand Down Expand Up @@ -257,12 +255,7 @@ public bool ShouldExcludeColumn(DataColumn column)
return true;
}

if (excludeColumnNamesByTableName.TryGetValue(column.Table.TableName, out HashSet<string> excludeColumnsForTable)
&& excludeColumnsForTable.Contains(column.ColumnName))
{
return true;
}

return false;
return excludeColumnNamesByTableName.TryGetValue(column.Table.TableName, out HashSet<string> excludeColumnsForTable)
&& excludeColumnsForTable.Contains(column.ColumnName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using FluentAssertions.DataSets;
using JetBrains.Annotations;

// ReSharper disable once CheckNamespace
namespace FluentAssertions;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Data;
using System.Linq;
using FluentAssertions.Collections;
using FluentAssertions.Common;
using FluentAssertions.DataSets.Common;
using FluentAssertions.Execution;

Expand Down
2 changes: 2 additions & 0 deletions Src/FluentAssertions.DataSets/DataTableAssertionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Data;
using System.Diagnostics;
using FluentAssertions.DataSets;
using JetBrains.Annotations;

// ReSharper disable once CheckNamespace
namespace FluentAssertions;

/// <summary>
Expand Down
3 changes: 1 addition & 2 deletions Src/FluentAssertions.DataSets/DataTableAssertions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
using System.Data;
using System.Diagnostics;
using System.Linq;
using FluentAssertions.DataSets;
using FluentAssertions.DataSets.Common;
using FluentAssertions.Equivalency;
using FluentAssertions.Execution;
using FluentAssertions.Primitives;

namespace FluentAssertions;
namespace FluentAssertions.DataSets;

/// <summary>
/// Provides convenient assertion methods on a <see cref="DataTable"/> that can be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Data;
using System.Linq;
using FluentAssertions.Collections;
using FluentAssertions.Common;
using FluentAssertions.DataSets.Common;
using FluentAssertions.Execution;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ protected override EquivalencyResult OnHandle(Comparands comparands, IEquivalenc
IEquivalencyValidator nestedValidator)
{
var subject = comparands.Subject as DataColumn;
var expectation = comparands.Expectation as DataColumn;

if (expectation is null)
if (comparands.Expectation is not DataColumn expectation)
{
if (subject is not null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ protected override EquivalencyResult OnHandle(Comparands comparands, IEquivalenc
IEquivalencyValidator nestedValidator)
{
var subject = comparands.Subject as DataRelation;
var expectation = comparands.Expectation as DataRelation;

if (expectation is null)
if (comparands.Expectation is not DataRelation expectation)
{
if (subject is not null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,7 @@ public bool Equals(CompoundKey other)
return false;
}

if (values.Length != other.values.Length)
{
return false;
}

return values.SequenceEqual(other.values);
return values.Length == other.values.Length && values.SequenceEqual(other.values);
}

public override bool Equals(object obj) => Equals(obj as CompoundKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ protected override EquivalencyResult OnHandle(Comparands comparands, IEquivalenc
IEquivalencyValidator nestedValidator)
{
var subject = comparands.Subject as DataRow;
var expectation = comparands.Expectation as DataRow;

if (expectation is null)
if (comparands.Expectation is not DataRow expectation)
{
if (subject is not null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ protected override EquivalencyResult OnHandle(Comparands comparands, IEquivalenc
IEquivalencyValidator nestedValidator)
{
var subject = comparands.Subject as DataTable;
var expectation = comparands.Expectation as DataTable;

if (expectation is null)
if (comparands.Expectation is not DataTable expectation)
{
if (subject is not null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Linq;
using FluentAssertions.DataSets.Equivalency;
using FluentAssertions.Equivalency.Steps;
using FluentAssertions.Xml;

namespace FluentAssertions.DataSets;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</PropertyGroup>

<PropertyGroup Label="Package info">
<Authors>Dennis Doomen;Jonas Nyrup</Authors>
<Authors>Dennis Doomen;Jonathan Gilbert</Authors>
<PackageDescription>
Extensions to Fluent Assertions for dealing with DataSets and DataTables.
</PackageDescription>
Expand Down Expand Up @@ -59,7 +59,7 @@
<PackagePath>contentFiles\any\any\</PackagePath>
</None>
</ItemGroup>

<!-- Target framework dependent configuration -->
<Choose>
<When Condition="'$(TargetFramework)' == 'net6.0'">
Expand Down
2 changes: 1 addition & 1 deletion Src/FluentAssertions.DataSets/RowMatchMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ public enum RowMatchMode
/// <see cref="DataTable"/> objects with exactly equivalent <see cref="DataTable.PrimaryKey"/>
/// configuration.
/// </summary>
PrimaryKey,
PrimaryKey
}
2 changes: 1 addition & 1 deletion Tests/Approval.Tests/ApiApproval.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public Task ApproveApi(string frameworkVersion)
private static string GetSourceDirectory([CallerFilePath] string path = "") => Path.GetDirectoryName(path);

// Copied from https://github.com/VerifyTests/Verify.DiffPlex/blob/master/src/Verify.DiffPlex/VerifyDiffPlex.cs
public static Task<CompareResult> OnlyIncludeChanges(string received, string verified, IReadOnlyDictionary<string, object> _)
private static Task<CompareResult> OnlyIncludeChanges(string received, string verified, IReadOnlyDictionary<string, object> _)
{
var diff = InlineDiffBuilder.Diff(verified, received);

Expand Down
10 changes: 5 additions & 5 deletions Tests/Approval.Tests/Approval.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="7.0.0-alpha.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="xunit" Version="2.5.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="PublicApiGenerator" Version="11.0.0" />
<PackageReference Include="Verify.DiffPlex" Version="2.2.1" />
<PackageReference Include="Verify.Xunit" Version="20.6.0" />
<PackageReference Include="Verify.DiffPlex" Version="2.3.0" />
<PackageReference Include="Verify.Xunit" Version="22.1.4" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,9 @@ namespace FluentAssertions
}
public static class DataTableAssertionExtensions
{
public static FluentAssertions.DataTableAssertions<TDataTable> Should<TDataTable>(this TDataTable actualValue)
public static FluentAssertions.DataSets.DataTableAssertions<TDataTable> Should<TDataTable>(this TDataTable actualValue)
where TDataTable : System.Data.DataTable { }
}
public class DataTableAssertions<TDataTable> : FluentAssertions.Primitives.ReferenceTypeAssertions<System.Data.DataTable, FluentAssertions.DataTableAssertions<TDataTable>>
where TDataTable : System.Data.DataTable
{
public DataTableAssertions(TDataTable dataTable) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<FluentAssertions.DataTableAssertions<TDataTable>> BeEquivalentTo(System.Data.DataTable expectation, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<FluentAssertions.DataTableAssertions<TDataTable>> BeEquivalentTo(System.Data.DataTable expectation, System.Func<FluentAssertions.DataSets.IDataEquivalencyAssertionOptions<System.Data.DataTable>, FluentAssertions.DataSets.IDataEquivalencyAssertionOptions<System.Data.DataTable>> config, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndWhichConstraint<FluentAssertions.DataTableAssertions<TDataTable>, System.Data.DataColumn> HaveColumn(string expectedColumnName, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<FluentAssertions.DataTableAssertions<TDataTable>> HaveColumns(params string[] expectedColumnNames) { }
public FluentAssertions.AndConstraint<FluentAssertions.DataTableAssertions<TDataTable>> HaveColumns(System.Collections.Generic.IEnumerable<string> expectedColumnNames, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<FluentAssertions.DataTableAssertions<TDataTable>> HaveRowCount(int expected, string because = "", params object[] becauseArgs) { }
}
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) { }
Expand Down Expand Up @@ -102,6 +90,18 @@ namespace FluentAssertions.DataSets
public FluentAssertions.AndConstraint<FluentAssertions.DataSets.DataSetAssertions<TDataSet>> HaveTables(params string[] expectedTableNames) { }
public FluentAssertions.AndConstraint<FluentAssertions.DataSets.DataSetAssertions<TDataSet>> HaveTables(System.Collections.Generic.IEnumerable<string> expectedTableNames, string because = "", params object[] becauseArgs) { }
}
public class DataTableAssertions<TDataTable> : FluentAssertions.Primitives.ReferenceTypeAssertions<System.Data.DataTable, FluentAssertions.DataSets.DataTableAssertions<TDataTable>>
where TDataTable : System.Data.DataTable
{
public DataTableAssertions(TDataTable dataTable) { }
protected override string Identifier { get; }
public FluentAssertions.AndConstraint<FluentAssertions.DataSets.DataTableAssertions<TDataTable>> BeEquivalentTo(System.Data.DataTable expectation, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<FluentAssertions.DataSets.DataTableAssertions<TDataTable>> BeEquivalentTo(System.Data.DataTable expectation, System.Func<FluentAssertions.DataSets.IDataEquivalencyAssertionOptions<System.Data.DataTable>, FluentAssertions.DataSets.IDataEquivalencyAssertionOptions<System.Data.DataTable>> config, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndWhichConstraint<FluentAssertions.DataSets.DataTableAssertions<TDataTable>, System.Data.DataColumn> HaveColumn(string expectedColumnName, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<FluentAssertions.DataSets.DataTableAssertions<TDataTable>> HaveColumns(params string[] expectedColumnNames) { }
public FluentAssertions.AndConstraint<FluentAssertions.DataSets.DataTableAssertions<TDataTable>> HaveColumns(System.Collections.Generic.IEnumerable<string> expectedColumnNames, string because = "", params object[] becauseArgs) { }
public FluentAssertions.AndConstraint<FluentAssertions.DataSets.DataTableAssertions<TDataTable>> HaveRowCount(int expected, string because = "", params object[] becauseArgs) { }
}
public static class EquivalencyAssertionOptionsExtensions
{
public static void AddDataSetSupport(this FluentAssertions.EquivalencyPlan plan) { }
Expand Down
Loading

0 comments on commit eca2d43

Please sign in to comment.