-
-
Notifications
You must be signed in to change notification settings - Fork 540
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
Add NotContainItemsAssignableTo
#2266
Merged
dennisdoomen
merged 8 commits into
fluentassertions:develop
from
Leo506:NotContainItemsAssignableTo
Aug 19, 2023
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
394f93d
NotContainItemsAssignableTo
Leo506 913918f
releases.md
Leo506 1dbdbf8
Update docs/_pages/releases.md
Leo506 378503f
fix comments
Leo506 dd45dfb
fix
Leo506 fb0a648
remove redundant directives
Leo506 be83099
TExpectation
Leo506 026533c
releases.md and collections.md
Leo506 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...luentAssertions.Specs/Collections/CollectionAssertionSpecs.NotContainItemsAssignableTo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System; | ||
using Xunit; | ||
using Xunit.Sdk; | ||
|
||
namespace FluentAssertions.Specs.Collections; | ||
|
||
public partial class CollectionAssertionSpecs | ||
{ | ||
public class NotContainItemsAssignableTo | ||
{ | ||
[Fact] | ||
public void Succeeds_when_the_collection_does_not_contain_items_of_the_unexpected_type() | ||
{ | ||
// Arrange | ||
var collection = new[] { "1", "2", "3" }; | ||
|
||
// Act / Assert | ||
collection.Should().NotContainItemsAssignableTo<int>(); | ||
} | ||
|
||
[Fact] | ||
public void Throws_when_the_collection_contains_an_item_of_the_unexpected_type() | ||
{ | ||
// Arrange | ||
var collection = new object[] { 1, "2", "3" }; | ||
|
||
// Act | ||
var act = () => collection | ||
.Should() | ||
.NotContainItemsAssignableTo<int>( | ||
"because we want test that collection does not contain object of {0} type", typeof(int).FullName); | ||
|
||
// Assert | ||
act.Should() | ||
.Throw<XunitException>() | ||
.WithMessage( | ||
"Expected collection to not contain any elements assignable to type \"System.Int32\" " + | ||
"because we want test that collection does not contain object of System.Int32 type, " + | ||
"but found {System.Int32, System.String, System.String}."); | ||
} | ||
|
||
[Fact] | ||
public void Succeeds_when_collection_is_empty() | ||
{ | ||
// Arrange | ||
var collection = Array.Empty<int>(); | ||
|
||
// Act / Assert | ||
collection.Should().NotContainItemsAssignableTo<int>(); | ||
} | ||
|
||
[Fact] | ||
public void Throws_when_the_passed_type_argument_is_null() | ||
{ | ||
// Arrange | ||
var collection = new[] { 1, 2, 3 }; | ||
|
||
// Act | ||
var act = () => collection.Should().NotContainItemsAssignableTo(null); | ||
|
||
// Assert | ||
act.Should().Throw<ArgumentNullException>(); | ||
} | ||
|
||
[Fact] | ||
public void Throws_when_the_collection_is_null() | ||
{ | ||
// Arrange | ||
int[] collection = null; | ||
|
||
// Act | ||
var act = () => collection.Should().NotContainItemsAssignableTo<int>(); | ||
|
||
// Assert | ||
act.Should() | ||
.Throw<XunitException>() | ||
.WithMessage( | ||
"Expected collection to not contain any elements assignable to type \"System.Int32\", but found <null>."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙃 I'm not quite fond of verifying the literal text and prefer to only assert some of the relevant parts match.