Skip to content

Conversation

@dennisdoomen
Copy link
Member

@dennisdoomen dennisdoomen commented Sep 25, 2018

Introduces a ClearExpectation to undo the expectation that is associated with multiple assertions using WithExpectation. Without it, it is possible that this expectation gets appended to any successive assertions.

Fixes #918

@dennisdoomen dennisdoomen changed the title [WIP] Ensures expectations involving multiple assertions can be cleared Ensures expectations involving multiple assertions can be cleared Sep 25, 2018
@dennisdoomen dennisdoomen requested a review from jnyrup September 25, 2018 19:32
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.

I'm not sure what the functional consequences are?

/// Indicates that every argument passed into <see cref="FailWith"/> is displayed on a separate line.
/// </summary>
public AssertionScope UsingLineBreaks
public IAssertionScope UsingLineBreaks
Copy link
Member

Choose a reason for hiding this comment

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

🤔 As IAssertionScope doesn't have all the public members of AssertionScope this is a breaking change

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure. The members of IAssertionScope are only used in chaining scenarios. I've included a couple of them, but not all. Any strong opinions?

Copy link
Member

Choose a reason for hiding this comment

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

I haven't tried to invoke AssertionScope-only members myself, I just looked for changes that could break the public API.

Copy link
Member Author

Choose a reason for hiding this comment

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

Normally, you're directly using the AssertionScope in a using block. The interface is only used for those complex chaining purposes. In the last commit, I've added almost all of them to the interface, just to be sure.

Copy link
Member

Choose a reason for hiding this comment

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

But no, I don't have any strong opinions, except trying to avoid breaking changes.

Just as a note: the remaining differences between AssertionScope and IAssertionScope are:

public string Context { get; set; }
public void AddPreFormattedFailure(string formattedFailureMessage);
void AddNonReportable(string key, object value);
void AddReportable(string key, string value);
T Get<T>(string key);

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I know. These are very specific things, mostly only used by BeEquivalentTo.

Copy link
Member Author

Choose a reason for hiding this comment

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

So? Approved?

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.

Would these changes benefit from any tests exercising the code?

@dennisdoomen
Copy link
Member Author

I'm in doubt. I would have to check whether the failure doesn't contain anything else. Not sure if it's worth though. I'll check when I continue with #911.

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.

2 participants