-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
#1107 Do no set default visibility and affiliation values to avoid mixing with type #1132
Merged
shiftkey
merged 3 commits into
octokit:master
from
AlexP11223:fix-type-and-visibility-affilation-mix-1107
Mar 10, 2016
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Xunit; | ||
|
||
namespace Octokit.Tests.Models | ||
{ | ||
public class RepositoryRequestTests | ||
{ | ||
public class TheToParametersDictionaryMethod | ||
{ | ||
[Fact] | ||
public void ContainsSetValues() | ||
{ | ||
var request = new RepositoryRequest | ||
{ | ||
Type = RepositoryType.All, | ||
Sort = RepositorySort.FullName, | ||
Direction = SortDirection.Ascending | ||
}; | ||
|
||
var parameters = request.ToParametersDictionary(); | ||
|
||
Assert.Equal(3, parameters.Count); | ||
Assert.Equal("all", parameters["type"]); | ||
Assert.Equal("full_name", parameters["sort"]); | ||
Assert.Equal("asc", parameters["direction"]); | ||
|
||
request = new RepositoryRequest | ||
{ | ||
Affiliation = RepositoryAffiliation.All, | ||
Visibility = RepositoryVisibility.Public | ||
}; | ||
|
||
parameters = request.ToParametersDictionary(); | ||
|
||
Assert.Equal(2, parameters.Count); | ||
Assert.Equal("owner, collaborator, organization_member", parameters["affiliation"]); | ||
Assert.Equal("public", parameters["visibility"]); | ||
} | ||
|
||
[Fact] | ||
public void DoesNotReturnValuesForDefaultRequest() | ||
{ | ||
var request = new RepositoryRequest(); | ||
|
||
var parameters = request.ToParametersDictionary(); | ||
|
||
Assert.Empty(parameters); | ||
} | ||
} | ||
} | ||
} |
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
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
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.
Is this line necessary? The parameter array was still created correctly for me, even without this line...
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.
Without this line it does not go into
if (propertyType.IsEnumeration())
and somehow produces "All" instead of "all" + does not use[Parameter]
attribute.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.
Ah fair enough, I must admit I just quickly put the nullable properties on the request object and ran the existing integration tests which passed...
From what you're saying we might need more tests since the current ones didn't pick up the problem you highlighted...oops, obviously I don't have your new test which looks like it covers those scenarios 😀