Skip to content
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

Avoid keeping trx stream open in unit tests #4642

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Jan 14, 2025

TrxTests works by creating a MemoryStream, and mocking NewFileStream to return that instance. Then later, the tests tries to use that stream. For that reason, tests are passing a flag to prevent production code form disposing the stream.

This PR cleans up product code, but makes tests more verbose. Now, product code will always dispose, without any flag that's used by tests. However, the "fake" stream created by tests will create the XDocument that the test needs when Dispose is called. That way, we don't need the stream anymore and we use the XDocument.

@Evangelink How do you feel about this change? I generally don't like when there is a code path in product code that's test only and prefer more ugly tests but cleaner product code. That's a personal taste though.

@Youssef1313 Youssef1313 marked this pull request as draft January 14, 2025 18: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.

1 participant