diff --git a/VkNet.Tests/Categories/Users/UserGetTests.cs b/VkNet.Tests/Categories/Users/UserGetTests.cs index 6673abcab..4d33f7606 100644 --- a/VkNet.Tests/Categories/Users/UserGetTests.cs +++ b/VkNet.Tests/Categories/Users/UserGetTests.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using FluentAssertions; using VkNet.Enums; @@ -35,4 +35,27 @@ public void Get_Olesya_SingleUser() user.Sex.Should() .Be(Sex.Deactivated); } + + [Fact] + public void Get_Male_SingleUser() + { + Url = "https://api.vk.com/method/users.get"; + ReadCategoryJsonPath(nameof(Get_Male_SingleUser)); + + var users = Api.Users.Get(new List + { + 43136387 + }, ProfileFields.Military); + + users.Should() + .NotBeNull(); + + var user = users.FirstOrDefault(); + + user.Should() + .NotBeNull(); + + user.Military.Should() + .NotBeNullOrEmpty(); + } } \ No newline at end of file diff --git a/VkNet.Tests/TestData/Categories/Users/Get_Male_SingleUser.json b/VkNet.Tests/TestData/Categories/Users/Get_Male_SingleUser.json new file mode 100644 index 000000000..2eedec0ec --- /dev/null +++ b/VkNet.Tests/TestData/Categories/Users/Get_Male_SingleUser.json @@ -0,0 +1,19 @@ +{ + "response": [ + { + "id": 43136387, + "military": [ + { + "unit": "145 отдельный инженерно-саперный батальон 31 Висленской танковой", + "unit_id": 3363063, + "from": 1986, + "until": 1988 + } + ], + "first_name": "Влад", + "last_name": "Невідомий", + "can_access_closed": true, + "is_closed": false + } + ] +} \ No newline at end of file diff --git a/VkNet/Model/User.cs b/VkNet/Model/User.cs index 2adf8579c..0aad53d6e 100644 --- a/VkNet/Model/User.cs +++ b/VkNet/Model/User.cs @@ -402,7 +402,7 @@ private string Name /// Информация о военной службе пользователя. /// [JsonProperty("military")] - public Military Military { get; set; } + public Military[] Military { get; set; } /// /// Любимые фильмы пользователя. diff --git a/VkNet/Utils/JsonConverter/UserJsonConverter.cs b/VkNet/Utils/JsonConverter/UserJsonConverter.cs index 9d703158b..675f93e79 100644 --- a/VkNet/Utils/JsonConverter/UserJsonConverter.cs +++ b/VkNet/Utils/JsonConverter/UserJsonConverter.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.ObjectModel; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -199,7 +199,7 @@ public override User ReadJson(JsonReader reader, Type objectType, User existingV .ToString()), Military = !response.ContainsKey("military") ? null - : JsonConvert.DeserializeObject(response["military"] + : JsonConvert.DeserializeObject(response["military"] .ToString()), Blacklisted = response["blacklisted"], BlacklistedByMe = response["blacklisted_by_me"],