-
Notifications
You must be signed in to change notification settings - Fork 256
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
feat: introduce convenience methods into MockFileSystem #951
feat: introduce convenience methods into MockFileSystem #951
Conversation
I realize the PR title workflow is failing, however I would like the project maintainers to introduce whatever prefix they deem appropriate when they squash merge my PR into the mainline. Thank you. |
Just a quick question from my side: Why not add it as extension methods in this repository? |
I didn't see a reason to add them as extension methods. Typically I only do that when I do not have access to the class in question. However, in my mind at least, the entire point of contributing these upstream (into this repo) was to make them a part of the class. I already have these as extension methods in my own code base and they were working fine. I'm unfamiliar with any design policies or preferences in this repo or of its its maintainers, so I went about this using my own judgement. Is there a problem with having them in the class itself? |
@rcdailey : I am just curious, if there is a specific reason why you implemented it this way, as you had to adapt the Are there disadvantages to extension methods that I am not aware of :-) |
I added them to the interface because everything else seemed to have been added there. I honestly didn't think too hard about it. Should I remove them from there? For my own understanding, how do you decide between adding to the interface or not? Happy to learn & adjust. I am not too strongly opinionated on how I went about this. I'm relying on you fine folks to let me know how it should be done :-) Thanks for the discussion! |
For what it's worth, I have these already in my own project as a set of extension methods. I'm happy to drop them in here just like this if that's what you want. Code is here. I think the reason I jumped right into making them part of the class was @fgreinacher's comment on the linked issue:
Maybe I read that too literally. It's honestly not a big deal either way. Let me know how you'd like it done. |
src/TestableIO.System.IO.Abstractions.TestingHelpers/IMockFileDataAccessor.cs
Outdated
Show resolved
Hide resolved
tests/TestableIO.System.IO.Abstractions.TestingHelpers.Tests/MockFileSystemTests.cs
Outdated
Show resolved
Hide resolved
I'd also tend to add them to |
70cc5d1
to
f86f663
Compare
I've force-pushed the requested changes and I've rebased onto latest changes in |
- `AddEmptyFile()` added which is a convenience wrapper for `AddFile()` with an empty `MockFileData`. - `AddFile()` overload added which consumes an `IFileInfo`. - `AddDirectory()` overload added which consumes an `IDirectoryInfo`. - `GetFile()` overload added which consumes an `IFileInfo`. Unit test added for `AddEmptyFile()` but not the others, as the test code for them would have very little value. Fixes TestableIO/System.IO.Abstractions.Extensions#32
f86f663
to
2c5f21e
Compare
Looks good to me now, thanks for your work! CI seems to be failing due to a .NET bug. We have to wait a bit until the fix is rolled out: dotnet/core#8194 (comment) |
…19.2.1 (#269) [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [TestableIO.System.IO.Abstractions](https://togithub.com/TestableIO/System.IO.Abstractions) | nuget | minor | `19.1.18` -> `19.2.1` | --- ### Release Notes <details> <summary>TestableIO/System.IO.Abstractions</summary> ### [`v19.2.1`](https://togithub.com/TestableIO/System.IO.Abstractions/releases/tag/v19.2.1) #### What's Changed - chore(deps): update dependency dotnet-sdk to v7.0.200 by [@​renovate](https://togithub.com/renovate) in [https://github.com/TestableIO/System.IO.Abstractions/pull/947](https://togithub.com/TestableIO/System.IO.Abstractions/pull/947) - chore(deps): update dependency benchmarkdotnet to v0.13.5 by [@​renovate](https://togithub.com/renovate) in [https://github.com/TestableIO/System.IO.Abstractions/pull/948](https://togithub.com/TestableIO/System.IO.Abstractions/pull/948) - chore(deps): update dependency microsoft.net.test.sdk to v17.5.0 by [@​renovate](https://togithub.com/renovate) in [https://github.com/TestableIO/System.IO.Abstractions/pull/949](https://togithub.com/TestableIO/System.IO.Abstractions/pull/949) - chore(deps): update dependency nunit3testadapter to v4.4.0 by [@​renovate](https://togithub.com/renovate) in [https://github.com/TestableIO/System.IO.Abstractions/pull/952](https://togithub.com/TestableIO/System.IO.Abstractions/pull/952) - chore(deps): update danielpalme/reportgenerator-github-action action to v5.1.18 by [@​renovate](https://togithub.com/renovate) in [https://github.com/TestableIO/System.IO.Abstractions/pull/953](https://togithub.com/TestableIO/System.IO.Abstractions/pull/953) - chore(deps): update dependency snapshooter.nunit to v0.13.0 by [@​renovate](https://togithub.com/renovate) in [https://github.com/TestableIO/System.IO.Abstractions/pull/954](https://togithub.com/TestableIO/System.IO.Abstractions/pull/954) - chore(deps): update dependency nunit3testadapter to v4.4.2 by [@​renovate](https://togithub.com/renovate) in [https://github.com/TestableIO/System.IO.Abstractions/pull/955](https://togithub.com/TestableIO/System.IO.Abstractions/pull/955) - feat: introduce convenience methods into MockFileSystem by [@​rcdailey](https://togithub.com/rcdailey) in [https://github.com/TestableIO/System.IO.Abstractions/pull/951](https://togithub.com/TestableIO/System.IO.Abstractions/pull/951) **Full Changelog**: TestableIO/System.IO.Abstractions@v19.1.18...v19.2.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/Testably/Testably.Abstractions). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xNTMuMiIsInVwZGF0ZWRJblZlciI6IjM0LjE1NC41In0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This is addressed in release v19.2.1. |
AddEmptyFile()
added which is a convenience wrapper forAddFile()
with an emptyMockFileData
.AddFile()
overload added which consumes anIFileInfo
.AddDirectory()
overload added which consumes anIDirectoryInfo
.GetFile()
overload added which consumes anIFileInfo
.Unit test added for
AddEmptyFile()
but not the others, as the test code for them would have very little value.Fixes TestableIO/System.IO.Abstractions.Extensions#32