Skip to content

Commit

Permalink
Remove a redundant length check in GenericDictionaryEquivalencyStep
Browse files Browse the repository at this point in the history
  • Loading branch information
aldelaro5 committed Apr 13, 2023
1 parent 0f25151 commit 93cba37
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
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)
{
return true;
}

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

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

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

var dataColumn1 = dataSet1.TypedDataTable1.DecimalColumn;
var dataColumn2 = dataSet2.TypedDataTable1.DecimalColumn;
var subject = subjectDataSet.TypedDataTable1.DecimalColumn;
var expectation = expectationDataSet.TypedDataTable1.DecimalColumn;

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

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

[Fact]
Expand Down
11 changes: 4 additions & 7 deletions Tests/FluentAssertions.Equivalency.Specs/DictionarySpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -498,14 +498,11 @@ public void When_a_generic_dictionary_is_typed_as_object_it_should_respect_the_r
public void When_a_generic_dictionary_is_typed_as_object_without_nesting_it_should_respect_the_runtime_typed()
{
// Arrange
object object1 = new Dictionary<string, string> { ["greeting"] = "hello" };
object object2 = new Dictionary<string, string> { ["greeting"] = "hello" };

// Act
Action act = () => object1.Should().BeEquivalentTo(object2, options => options.ExcludingNestedObjects());
object subject = new Dictionary<string, string> { ["greeting"] = "hello" };
object expectation = new Dictionary<string, string> { ["greeting"] = "hello" };

// Assert
act.Should().NotThrow();
// Act & Assert
subject.Should().BeEquivalentTo(expectation, options => options.ExcludingNestedObjects());
}

[Fact]
Expand Down

0 comments on commit 93cba37

Please sign in to comment.