Skip to content
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

Code coverage improvements #2180

Merged
merged 3 commits into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ private static bool AssertExpectationIsNotNull(object subject, object expectatio
// the AssertSameLength method.
where TExpectedKey : TSubjectKey
{
if (expectation.Count == subject.Count)
jnyrup marked this conversation as resolved.
Show resolved Hide resolved
{
return true;
}

KeyDifference<TSubjectKey, TExpectedKey> keyDifference = CalculateKeyDifference(subject, expectation);

bool hasMissingKeys = keyDifference.MissingKeys.Count > 0;
Expand Down
18 changes: 18 additions & 0 deletions Tests/FluentAssertions.Equivalency.Specs/DataColumnSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,24 @@ public void When_DataColumn_has_changes_but_is_excluded_it_should_succeed()
.ExcludingColumn(dataColumn2));
}

[Fact]
public void Can_exclude_a_column_from_all_tables()
{
// Arrange
var subjectDataSet = CreateDummyDataSet<TypedDataSetSubclass>();
var expectationDataSet = new TypedDataSetSubclass(subjectDataSet);

var subject = subjectDataSet.TypedDataTable1.DecimalColumn;
var expectation = expectationDataSet.TypedDataTable1.DecimalColumn;

expectation.Unique = true;
expectation.Caption = "Test";

// Act & Assert
subject.Should().BeEquivalentTo(expectation, options => options
.ExcludingColumnInAllTables(expectation.ColumnName));
}

[Fact]
public void When_DataColumn_has_changes_but_is_excluded_as_params_it_should_succeed()
{
Expand Down
18 changes: 18 additions & 0 deletions Tests/FluentAssertions.Equivalency.Specs/DataTableSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,24 @@ public void When_data_table_name_does_not_match_and_the_corresponding_property_i
.WithMessage("Expected dataTable1 to have TableName *different*, but found *TypedDataTable1* instead*");
}

[Fact]
public void When_excluding_invalid_constraint_it_should_throw()
{
// Arrange
var typedDataSet = CreateDummyDataSet<TypedDataSetSubclass>();

var subject = typedDataSet.ToUntypedDataSet().Tables["TypedDataTable1"];
var expectation = typedDataSet.ToUntypedDataSet().Tables["TypedDataTable1"];

// Act
Action action = () => subject.Should().BeEquivalentTo(expectation, options => options
.ExcludingRelated((Constraint constraint) => new object()));

// Assert
action.Should().Throw<ArgumentException>().WithMessage(
"*Expression must be a simple member access*");
}

[Fact]
public void When_data_table_name_does_not_match_but_the_corresponding_property_is_excluded_equivalence_test_should_succeed()
{
Expand Down