forked from octokit/octokit.net
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add unit tests for CreateFile DeleteFile and UpdateFile #2
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will it not work if you check the parameters of the CreateFileRequest object?
Or is that an exercise left for the reader? ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well the way i typically like to write unit tests is that each one has a specific focus/task to check. EG this test is to check that the correct URL is used, therefore using the mocked out IApiConnection, it checks that the first parameter is a Uri that matches exactly what we expect to be called... but it's job isnt to check the 2nd parameter so it just ensures that it is "any object".
Then there is another test that checks the 2nd parameter (PassesRequestObject) and in that one it doesnt care what the Uri was (just Arg.Any) but it checks every field on the CreateFileRequest object was passed through. So if you had a bug in the constructor where you swapped fields, or didnt populate the branch etc, that test would fail
In this way we have discrete unit tests and if one fails we will know the problem (didnt call correct Uri for example). whereas if you have a unit test that does 10 things in a row and it fails, you have to go digging into the exception to figure out what part of the test failed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I missed the second test..
Let's just blame it on the fact that I am on my phone. 😄