Skip to content

Conversation

@Serg046
Copy link
Contributor

@Serg046 Serg046 commented Oct 27, 2020

IMPORTANT

  • The code complies with the Coding Guidelines for C#.
  • The changes are covered by a new or existing set of unit tests which follow the Arrange-Act-Assert syntax such as is used in this example.
  • If the contribution adds a feature or fixes a bug, please update the release notes, which are published on the website.
  • If the contribution changes the public API the changes needs to be included by running AcceptApiChanges.ps1/AcceptApiChanges.sh.
  • If the contribution affects the documentation, please include your changes in this pull request so the documentation will appear on the website.

Issue #1160

@Serg046
Copy link
Contributor Author

Serg046 commented Oct 27, 2020

ThenNotBeInAscendingOrder and ThenNotBeInDescendingOrder are not provided because it will significantly complicate the change. The issue is the following lines of NotBeOrderedBy:

Execute.Assertion
    .ForCondition(!unordered.SequenceEqual(expectation))
    .BecauseOf(because, becauseArgs)
    .FailWith("Expected {context:collection} {0} to not be ordered {1}{reason} and not result in {2}.",
        Subject, orderString, expectation);

It would be much more complex than just !unordered.SequenceEqual(expectation).
Anyway, I don't think it is worth implementing because even if they were implemented, it would be difficult to understand their behavior therefore they would be in rare use.

Copy link
Member

@dennisdoomen dennisdoomen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice work.
❌ Please update the title to be functional

namespace FluentAssertions.Collections
{
[DebuggerNonUserCode]
public class SubsequentOrderingGenericCollectionAssertions<T> :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Maybe rename it to SubsequentOrderingAssertions?

* Added `ComparingBy{Members,Value}(Type)` to allow specifying open generic types - [#1389](https://github.com/fluentassertions/fluentassertions/pull/1389).
* Added overload of `CollectionAssertions.NotBeEquivalentTo` that takes a `config` parameter` - [#1408](https://github.com/fluentassertions/fluentassertions/pull/1408).
* Changed `StringAssertions.StartWith`, `StringAssertions.EndWith` and their `EquivalentOf` versions to allow empty strings - [#1413](https://github.com/fluentassertions/fluentassertions/pull/1413).
* Added ThenBeInAscendingOrder and ThenBeInDescendingOrder to allow asserting that a subsequence is ordered in ascending or descending order - [#1416](https://github.com/fluentassertions/fluentassertions/pull/1416).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙃 Would be nice to format those names using back-ticks.

#region Then be in order

[Fact]
public void When_asserting_subsequence_by_then_be_in_ascending_order_it_should_pass()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 Try to keep the names of test functional and never refer to the literal name of a method or API, e.g.

When_the_collection_is_ordered_according_to_the_subsequent_ordering_assertion_it_should_succeed

Copy link
Member

@jnyrup jnyrup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this support multiple ThenBeInAscendingOrder?
E.g.

collection.Should()
	.BeInAscendingOrder(x => x.Item1)
	.And
	.ThenBeInAscendingOrder(x => x.Item2)
	.And
	.ThenBeInAscendingOrder(x => x.Item3);

@Serg046
Copy link
Contributor Author

Serg046 commented Oct 28, 2020

Applied the notes and added two tests showing multiple ThenBeInAscending(Descending)Order support

@Serg046 Serg046 changed the title Issue 1160 Order by multiple properties sequentially Oct 28, 2020
@dennisdoomen dennisdoomen merged commit 0a1fa2c into fluentassertions:develop Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants