Commit Graph

34 Commits

Author SHA1 Message Date
notauserx 891015c39f update models with updated permission enum (#2633)
* update models with updated permission enum

* add suppress message attribute

* update integration tests

* refactor: new and legacy update teams endpint

* refactor: add new delete team endpoint

* use TeamPermission on NewTeam

* use updated delete on team context dispose

* add permission enum for team response object

* refactor: remove legacy suffix from method names

* introduce permissions object on Team

* refactor: rename enum to TeamRepositoryPermission

* fix formatting

* change Permission to string to match api specs

* add TeamRepository

* add CheckTeamPermission endpoint support

* fix convention tests

* update comments on TeamRepository props

* add two new endpoints in TeamsClient

* refactor: rename ApiUrl for TeamPermission

* fix test

* implement methods for new endpoints

* add the integration tests

* fix spelling

* update comments

* refactor: rename method name

* fix: add end tag for remarks

* refactor: remove unused method param

* fix docstring comment

* the unit tests are in finally

* add docs for teams api

* split CheckTeamPermissions into two methods

* Update ObservableTeamsClientTests.cs based on review

Co-authored-by: Keegan Campbell <me@kfcampbell.com>

* add cref to legacy update and delete endpoints

* remove editorconfig file

* Update Octokit.Tests/Clients/TeamsClientTests.cs

Co-authored-by: Keegan Campbell <me@kfcampbell.com>

* remove unused line

* rename variable based on review

* rename prop to match constructor param

* add comment to explain TeamPermission enum values on update

Co-authored-by: notauserx <notauserx@users.noreply.github.com>
Co-authored-by: Keegan Campbell <me@kfcampbell.com>
2023-01-20 10:48:00 -08:00
Brendan Forster e9516bb6c1 bugfix: improve fallback when StringEnum encounters null value (#2156) 2020-03-17 15:09:15 -03:00
Brendan Forster 45bc5eced7 autofix tests based on feedback from xunit analyzers (#1997) 2019-09-16 19:46:40 -03:00
Ryan Gribble 41b4059c11 Deserializer should handle nullable StringEnum<T> (#1760)
* add deserializer tests for nullable enums, StringEnum and nullable StringEnum properties

* Fix deserializing nullable structs by using the underlying type when nullable

* StringEnum<T> should behave like an enum, returning default(T) when it is uninitialised/null/blank

* Don't allow null to be passed into StringEnum ctor - if it needs to be null then it should be declared as nullable

* fix expected json

* move logic to determine if property is a StringEnum<T> into helper function

* serializer needs to treat StringEnum<T> specially by serializing the enum value according to existing serializer strategy (parameter attributes and so on)

* remove fallback to default(T)

* add test to assert ctor throws exception when null passed in

* remove test for default(T) fallback behaviour

* Fix exception in serializer test - StringEnum property must be initialized otherwise an exception is thrown when attempting to serialize

* Dont allow empty strings either
2018-02-16 20:12:44 +10:00
Itai Bar-Haim da3bbe3d0c Added support for DateTime serialized as FileTime (#1735)
* added support for DateTime serialized as FileTime

* changed non-iso timestamp deserialization from FromFileTime to FromUnixTime.

* updated a test to also test the new time stamp deserializer.

* moved all tests projects to a solution folder of their own.

* Fixed test and added a missing field to Account.

* Use original values in test.

* Moved UpdatedAt from Account to User.
2018-01-18 19:23:10 +10:00
Kristian Hellang 5ee4d64046 Add StringEnum to handle unknown enum values returned from API (#1595)
* Added StringEnum<TEnum>

* Added tests

* Make sure the serializer can work with StringEnum

* Use StringEnum for EventInfo.Event

* Add convention test to assert that all Response models use StringEnum<> to wrap enum properties

* Add Stringnum<> to all response types failing convention test

* Handle StringEnum to Enum conversion when Issue response model populates IssueUpdate request model

* Fix unit test

* Refactor SimpleJsonSerializer to expose the DeserializeEnum strategy so it can be used in StringEnum class

* Need to expose/use SerializeEnum functionality too, so we use the correct string representation of enum values that have custom properties (eg ReactionType Plus1 to "+1")

* fix unit tests, since the string is now the "correct" upstream api value

* Add a couple of tests for the Enum serialize/deserialize when underscores, hyphens and custom property attributes are present

* Compare parsed values for equality

* add convention test to ensure enum members all have Parameter property set

* update test to cover implicit conversions too

* this test should work but fails at the moment due to magic hyphen removal in deserializer causing a one way trip from utf-8 to EncodingType.Utf8 with no way to get back

* (unsuccesfully) expand event info test to try to catch more cases of unknown event types

* fix broken integration test while im here

* Fixed build errors after .NET Core merge

* Value -> StringValue, ParsedValue -> Value

* Don't allow StringValue to be null

* Ignore enums not used in request/response models

* Added ParameterAttribute to almost all enum values

* Ignore Language enum

* Fix failing tests

* Fix milestone sort parameter and tests

* whitespace

* fix milestone unit tests

* Fix StringEnum.Equals ... This could've been embarrassing!

* Change SimpleJsonSerializer Enum handling to only use `[Parameter()]` attributes (no more magic removal of hyphen/underscores from strings)

* Tidy up this integration test while im here

* Only test request/response enums in convention test

* Keep skipping Language

* Remove unused method

* Remove excluded enum types

* Removed unnecessary ParameterAttributes

* Remove unused enum

* Add StringEnum test for string-comparison of two invalid values

* Bring back IssueCommentSort and use it in IssueCommentRequest

This reverts commit 38a4a291d1476ef8c992fe0f76956974b6f32a49.

* Use assembly instead of namespace for Octokit check

* Add failing test to reproduce the issue where only the first enum paramter/value was added to the cache

* Fix deserializer enum cache to include all enum members rather than only the first member encountered

* Use a static SimpleJsonSerializer in StringEnum

* Remove serializer instance in StringEnum

* Add some documentation on StringEnum<TEnum>

* Fix parameter value to resolve failing integration test
2017-06-25 19:29:57 +10:00
Ryan Gribble 3c818934b8 Release v0.24 - A Sight For Sore Eyes (#1539)
* Add release notes and bump version to 0.24

* run "build FormatCode" to fix up whitespace/formatting issues

* Fix failing Ssh key tests due to "validation exception".  This key must be in use on github (under another user, most likely from these tests failing).  Changed to a new SSH key and tweaked tests to reduce chance of a key being created and not destroyed

* Assignee and Assignees cant both be specified on NewIssue.  We missed this one in the PR.  Marked Assignee as [Obsolete] and fixed tests to use Assignees

* Fix a couple of Reactions tests that were calling the wrong client methods

* Fix timeline tests - looks like the response class has changed shape a bit, it now has an Issue object in the payload and Id field isnt present (leaving Id field there in case other timeline events do use it)

* Fix some following tests that require the test user to follow more than 1 other user

* Unskip these Event tests now because apparently they work!

* add breaking changes notes

* Update ApiErrorMessageSafe to return null for empty and whitespace strings (#1540)

* return null if ApiError.Message is empty or whitespace

* Uncomment test, which now passes

* update release notes to include PR1540

* Add "Bot" AccountType, was causing a deserialization exception when running the integration test "SearchForExcludedLanguage" (#1541)

* Update to include PR1541

* add bullets to make release notes easier to read

* markup additional code mentions in notes

* Fix grammar

fields => field
2017-01-17 18:56:55 +10:00
Phil Haack d42fcb79be Add some unit tests for enum serialization 2016-06-30 14:54:11 -07:00
aedampir@gmail.com c99d0d68e3 Some redundant parentheses were fixed. 2016-03-25 13:19:49 +07:00
Ryan Gribble 3b74250abf - Add unit tests to assert expected behaviour when deserializing strings containing hyphens (and underscores for good measure) into a string and List<string> objects
- Fix failing List<string> test by removing the seemingly redundant line in the deserializer
2016-02-05 21:04:02 +10:00
Brendan Forster 6bedf1ee9b just a bit of code cleanup 2016-02-02 10:01:16 +10:30
Naveen e88a6c3d0b Checked for the serialized data
Compared if the serialized data has what was expected. Not just
deserialized data.
2015-12-05 19:57:06 -05:00
Naveen 2bb4682e7a Tests for Unicode character serialization
Tests for Unicode character serialization
2015-12-05 18:54:23 -05:00
Brendan Forster 80719c0033 aaaand format the code 2015-11-04 13:38:51 -08:00
Jan Ove Skogheim 46e572131f Ignore underscores when parsing enums under deserialization. 2015-02-25 22:36:18 +01:00
Micah a3d82484ce Adds truncated attribute to TreeResponse.
See https://developer.github.com/v3/git/trees/#get-a-tree for details on the truncated attribute.
2015-01-11 12:00:53 -08:00
Haacked 9f675924b7 Make response models readonly
It's bothered me that our response models are mutable. They really
shouldn't be. I made the properties have a protected setter instead of
private to provide flexibility for others who might be deriving from
these classes or testing them.

Fixes #650
2015-01-03 20:21:36 -08:00
Haacked 641b03de41 Improve support for base64 strings 2015-01-02 01:14:17 -08:00
Haacked 543d1bb863 Add support for deserializing non-public members
But only ones with ParameterAttribute applied.
2015-01-02 01:14:16 -08:00
Haacked 83bc99256a Add attribute to serialize strings as base64 encoded 2015-01-02 01:14:12 -08:00
Matt G. Ellis d0dcbe8fb6 Allow [Parameter] to control JSON Field Names.
Previously, SimpleJsonSerializer.MapClrMemberNameToJsonFieldName
special cased the name "Links" since while that was the name of the
property in the object model, in JSON "_links" was used instead.

It turns out that there was an additional problem, where GitReference
wants to expose as Repository, but the name in JSON responses is
"repo".  Instead of simply adding another special case to
MapClrMemberNameToJsonFieldName, we update the implementation of the
serializer to allow [Parameter(Key = "some_name")] to denote what name
we'd like to use for the field in the JSON object when we serialize.
2014-11-17 23:55:37 -08:00
Brendan Forster bb78757687 make the Hireable field a nullable bool, because API 2014-07-07 19:41:07 +09:30
Brendan Forster 5d3d4e7c35 added failing test 2014-07-07 19:39:18 +09:30
Haacked aaa010d790 Special case JSON _links property.
For some reason, the List Feeds http://developer.github.com/v3/activity/feeds/#list-feeds
API response has a field that starts with an underscore. This also occurs in
the Review Comments API: http://developer.github.com/v3/pulls/comments/#list-comments-in-a-repository
and in the Contents API. http://developer.github.com/v3/repos/contents/#get-the-readme

This commit special cases that one field so we can use the expected CLR
property name. I couldn't find a case where a
JSON response doesn't prefix "links" with an underscore.

Related to #386
2014-02-20 09:34:45 -08:00
John Nye d433eec548 Allow deserializing of base properties in SIMPE_JSON_TYPEINFO mode (works otherwise) 2013-11-07 21:28:06 -08:00
John Nye 93f18d5cab Move NewTag serialization test to TagClientTest 2013-11-04 18:42:59 +00:00
John Nye b5056a1346 Fix fate time utc expected result 2013-11-04 18:35:30 +00:00
John Nye 19b1b72365 Fix long json string 2013-11-04 18:33:48 +00:00
John Nye 951b03dbbc Fix DateTimeKind to UTC 2013-11-04 18:20:23 +00:00
John Nye 6bc2991abc Ensure NewTag serializes correctly 2013-11-02 08:23:03 +00:00
half-ogre 6f3fa81789 move internal stuff to .Internal namespace 2013-10-08 15:14:06 -07:00
half-ogre 77bf8f23e7 unit tests for serializer changes 2013-10-08 09:53:07 -07:00
Haacked 91b5449ddd Removed fluent assertions 2013-09-23 17:41:04 -07:00
Haacked 997e955f38 Rename to Octokit to be consistent with other API libs
GitHub is naming all of the libraries Octokit for their respective
platforms
2013-01-29 14:00:27 -08:00