-
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
В категорию Polls добавлены отсутствующие методы (#1194)
* Реализовал метод getBackgrounds #1130 * Добавил Json для теста метода getBackgrounds #1130 * Реализовал метода getPhotoUploadServer #1130 * Реализовал метод savePhoto #1130
- Loading branch information
1 parent
c04208c
commit 9721e52
Showing
14 changed files
with
407 additions
and
7 deletions.
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,32 @@ | ||
using NUnit.Framework; | ||
using VkNet.Enums.SafetyEnums; | ||
using VkNet.Tests.Infrastructure; | ||
|
||
namespace VkNet.Tests.Categories.Polls | ||
{ | ||
[TestFixture] | ||
public class GetBackgroundsTest : CategoryBaseTest | ||
{ | ||
protected override string Folder => "Polls"; | ||
|
||
[Test] | ||
public void GetBackgrounds() | ||
{ | ||
Url = "https://api.vk.com/method/polls.getBackgrounds"; | ||
|
||
ReadCategoryJsonPath(nameof(Api.PollsCategory.GetBackgrounds)); | ||
|
||
var result = Api.PollsCategory.GetBackgrounds(); | ||
|
||
Assert.That(result[0].Type, Is.TypeOf<PollBackgroundType>()); | ||
Assert.That(result[0].Angle, Is.EqualTo("225")); | ||
Assert.That(result[0].Points[0].Color, Is.EqualTo("f24973")); | ||
Assert.That(result[0].Points[0].Position, Is.EqualTo(0)); | ||
|
||
Assert.That(result[1].Type, Is.TypeOf<PollBackgroundType>()); | ||
Assert.That(result[1].Angle, Is.EqualTo("180")); | ||
Assert.That(result[1].Points[1].Color, Is.EqualTo("2f733f")); | ||
Assert.That(result[1].Points[1].Position, Is.EqualTo(1)); | ||
} | ||
} | ||
} |
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,23 @@ | ||
using NUnit.Framework; | ||
using VkNet.Tests.Infrastructure; | ||
|
||
namespace VkNet.Tests.Categories.Polls | ||
{ | ||
[TestFixture] | ||
public class GetPhotoUploadServerTest : CategoryBaseTest | ||
{ | ||
protected override string Folder => "Polls"; | ||
|
||
[Test] | ||
public void GetPhotoUploadServer() | ||
{ | ||
Url = "https://api.vk.com/method/polls.getPhotoUploadServer"; | ||
|
||
ReadCategoryJsonPath(nameof(Api.PollsCategory.GetPhotoUploadServer)); | ||
|
||
var result = Api.PollsCategory.GetPhotoUploadServer(450138623); | ||
|
||
Assert.IsNotEmpty(result.UploadUrl); | ||
} | ||
} | ||
} |
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,31 @@ | ||
using NUnit.Framework; | ||
using VkNet.Model.RequestParams; | ||
using VkNet.Tests.Infrastructure; | ||
|
||
namespace VkNet.Tests.Categories.Polls | ||
{ | ||
[TestFixture] | ||
public class PollsSavePhotoTest : CategoryBaseTest | ||
{ | ||
protected override string Folder => "Polls"; | ||
|
||
[Test] | ||
public void PollsSavePhoto() | ||
{ | ||
Url = "https://api.vk.com/method/polls.savePhoto"; | ||
|
||
ReadCategoryJsonPath(nameof(Api.PollsCategory.SavePhoto)); | ||
|
||
var result = Api.PollsCategory.SavePhoto(new SavePhotoParams | ||
{ | ||
Photo = "242344", | ||
Hash = "fe8f7aaa03ff650cc2" | ||
}); | ||
|
||
Assert.That(result.Id, Is.EqualTo(457245390)); | ||
Assert.That(result.Color, Is.EqualTo("BE272E")); | ||
Assert.That(result.Images[0].Height, Is.EqualTo(600)); | ||
Assert.IsNotEmpty(result.Images[0].Url.ToString()); | ||
} | ||
} | ||
} |
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,29 @@ | ||
{ | ||
"response": [{ | ||
"angle": 225, | ||
"color": "6248cb", | ||
"id": 1, | ||
"name": "фон в тёплых тонах", | ||
"points": [{ | ||
"color": "f24973", | ||
"position": 0 | ||
}, { | ||
"color": "3948e6", | ||
"position": 1 | ||
}], | ||
"type": "gradient" | ||
}, { | ||
"angle": 180, | ||
"color": "4b8642", | ||
"id": 2, | ||
"name": "зелёный фон", | ||
"points": [{ | ||
"color": "679945", | ||
"position": 0 | ||
}, { | ||
"color": "2f733f", | ||
"position": 1 | ||
}], | ||
"type": "gradient" | ||
}] | ||
} |
5 changes: 5 additions & 0 deletions
5
VkNet.Tests/TestData/Categories/Polls/GetPhotoUploadServer.json
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,5 @@ | ||
{ | ||
"response": { | ||
"upload_url": "https://pu.vk.com...jYjEwNzRjMTY4ZTIifQ" | ||
} | ||
} |
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,15 @@ | ||
{ | ||
"response": { | ||
"color": "BE272E", | ||
"id": 457245390, | ||
"images": [{ | ||
"height": 600, | ||
"url": "https://sun9-79.userapi.com/impf/M1JmC0VPcPYhRKB-emOIZwNX3ERNBdhpXHZBzw/gabphYGgM_Y.jpg", | ||
"width": 1001 | ||
}, { | ||
"height": 200, | ||
"url": "https://sun9-79.userapi.com/impf/M1JmC0VPcPYhRKB-emOIZwNX3ERNBdhpXHZBzw/gabphYGgM_Y.jpg", | ||
"width": 510 | ||
}] | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
|
||
namespace VkNet.Model.RequestParams | ||
{ | ||
/// <summary> | ||
/// Параметры для метода SavePhoto | ||
/// </summary> | ||
[Serializable] | ||
public class SavePhotoParams | ||
{ | ||
/// <summary> | ||
/// Строка полученная в результате загрузки фотографии. | ||
/// </summary> | ||
public string Photo { get; set; } | ||
|
||
/// <summary> | ||
/// Хеш полученный в результате загрузки фотографии. | ||
/// </summary> | ||
public string Hash { get; set; } | ||
} | ||
} |
Oops, something went wrong.