Skip to content

Commit

Permalink
Added tests that cover the situation where the subject is null to Dat…
Browse files Browse the repository at this point in the history
…aTableCollectionAssertionExtensionsSpecs.cs, DataColumnCollectionAssertionExtensionsSpecs.cs and DataRowCollectionAssertionExtensionSpecs.cs.

Corrected indentation error in DataRowCollectionAssertionExtensions.cs.
  • Loading branch information
logiclrd committed Feb 28, 2022
1 parent 2d54c82 commit db60b38
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,5 @@ public static class DataRowCollectionAssertionExtensions

return new AndConstraint<GenericCollectionAssertions<DataRow>>(assertion);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ public void When_references_are_different_it_should_succeed()

public class HaveSameCount
{
[Fact]
public void When_subject_is_null_it_should_fail()
{
// Arrange
var subject = default(DataColumnCollection);

var expectation = new DataTable().Columns;

// Act
Action action =
() => subject.Should().HaveSameCount(expectation, because: "we {0}", "care");

// Assert
action.Should().Throw<XunitException>().WithMessage(
"Expected * to have the same count as * because we care, but found <null>.*");
}

[Fact]
public void When_expectation_is_null_it_should_fail()
{
Expand Down Expand Up @@ -262,6 +279,23 @@ public void When_collection_is_compared_with_typed_collection_with_different_num

public class NotHaveSameCount
{
[Fact]
public void When_subject_is_null_it_should_fail()
{
// Arrange
var subject = default(DataColumnCollection);

var expectation = new DataTable().Columns;

// Act
Action action =
() => subject.Should().NotHaveSameCount(expectation, because: "we {0}", "care");

// Assert
action.Should().Throw<XunitException>().WithMessage(
"Expected * to not have the same count as * because we care, but found <null>.*");
}

[Fact]
public void When_expectation_is_null_it_should_fail()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,23 @@ public void When_references_are_different_it_should_succeed()

public class HaveSameCount
{
[Fact]
public void When_subject_is_null_it_should_fail()
{
// Arrange
var subject = default(DataRowCollection);

var expectation = new DataTable().Rows;

// Act
Action action =
() => subject.Should().HaveSameCount(expectation, because: "we {0}", "care");

// Assert
action.Should().Throw<XunitException>().WithMessage(
"Expected * to have the same count as * because we care, but found <null>.*");
}

[Fact]
public void When_expectation_is_null_it_should_fail()
{
Expand Down Expand Up @@ -302,6 +319,23 @@ public void When_collection_is_compared_with_typed_collection_with_different_num

public class NotHaveSameCount
{
[Fact]
public void When_subject_is_null_it_should_fail()
{
// Arrange
var subject = default(DataRowCollection);

var expectation = new DataTable().Rows;

// Act
Action action =
() => subject.Should().NotHaveSameCount(expectation, because: "we {0}", "care");

// Assert
action.Should().Throw<XunitException>().WithMessage(
"Expected * to not have the same count as * because we care, but found <null>.*");
}

[Fact]
public void When_expectation_is_null_it_should_fail()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,23 @@ public void When_references_are_different_it_should_succeed()

public class HaveSameCount
{
[Fact]
public void When_subject_is_null_it_should_fail()
{
// Arrange
var subject = default(DataTableCollection);

var expectation = new DataSet().Tables;

// Act
Action action =
() => subject.Should().HaveSameCount(expectation, because: "we {0}", "care");

// Assert
action.Should().Throw<XunitException>().WithMessage(
"Expected * to have the same count as * because we care, but found <null>.*");
}

[Fact]
public void When_expectation_is_null_it_should_fail()
{
Expand Down Expand Up @@ -277,6 +294,23 @@ public void When_collection_is_compared_with_typed_collection_with_different_num

public class NotHaveSameCount
{
[Fact]
public void When_subject_is_null_it_should_fail()
{
// Arrange
var subject = default(DataTableCollection);

var expectation = new DataSet().Tables;

// Act
Action action =
() => subject.Should().NotHaveSameCount(expectation, because: "we {0}", "care");

// Assert
action.Should().Throw<XunitException>().WithMessage(
"Expected * to not have the same count as * because we care, but found <null>.*");
}

[Fact]
public void When_expectation_is_null_it_should_fail()
{
Expand Down

0 comments on commit db60b38

Please sign in to comment.