X Tutup
Skip to content

Move to NUnit v4#6183

Merged
roji merged 5 commits intonpgsql:mainfrom
manandre:nunit-v4
Sep 8, 2025
Merged

Move to NUnit v4#6183
roji merged 5 commits intonpgsql:mainfrom
manandre:nunit-v4

Conversation

@manandre
Copy link
Copy Markdown
Collaborator

@manandre manandre commented Sep 6, 2025

No description provided.

Copy link
Copy Markdown
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

Thanks @manandre (and nice to see you again here 👋 ).

See some very minor comments below, otherwise LGTM.


protected virtual NpgsqlDataSource DataSource => DefaultDataSource;


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

await using var tx = await connection.BeginTransactionAsync();
Assert.Null(connection.Connector!.DatabaseInfo.CompositeTypes.SingleOrDefault(c => c.Name.Contains(table)));
Assert.Null(connection.Connector!.DatabaseInfo.ArrayTypes.SingleOrDefault(c => c.Name.Contains(table)));
Assert.That(connection.Connector!.DatabaseInfo.CompositeTypes.SingleOrDefault(c => c.Name.Contains(table)), Is.Null);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I definitely like that this removes AreEqual, replacing them with Is.EqualTo instead (making it clear what's the expected and what's the actual), but for Assert.Null it seems to mainly make the assertion more verbose... Is this something we have to do (because the analyzers recommend it), or can we not to do it?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Same feeling here.
NUnit v4 enforces the fluent syntax even if sometimes it makes the assertions more verbose.
The previous assert methods are still available in a ClassicAssert static class, but I would recommend to not mix both solutions in the same project.


var exception = await AssertTypeUnsupportedWrite(Mood.Happy, enumType);
Assert.IsInstanceOf<NotSupportedException>(exception.InnerException);
Assert.That(exception.InnerException, Is.InstanceOf<NotSupportedException>());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As with IsNull, previous seems slightly better to me...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Idem

{1}
Exception {2}",
i, FormatEventQueue(eventQueue), ex);
Assert.Fail($"Failed at iteration {i}.\r\nEvents:\r\n{FormatEventQueue(eventQueue)}\r\nException {ex}");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This doesn't look like a good change to me (especially since it encodes a particular type of newline sequence). I'd convert this to a raw literal string instead (""").

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Moved to raw strings

@manandre manandre requested a review from roji September 7, 2025 13:58
@roji roji merged commit 53b6028 into npgsql:main Sep 8, 2025
25 of 28 checks passed
@manandre manandre deleted the nunit-v4 branch September 8, 2025 21:32
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

X Tutup