Skip to content

Commit

Permalink
Добавить методы appWidgets (#929)
Browse files Browse the repository at this point in the history
* Добавить методы appWidgets

* Добавить тесты appWidgets
  • Loading branch information
Panuchi authored Feb 7, 2020
1 parent 3a03a7e commit 2606596
Show file tree
Hide file tree
Showing 27 changed files with 851 additions and 60 deletions.
26 changes: 26 additions & 0 deletions VkNet.Tests/Categories/AppWidgets/GetAppImageUploadServerTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Diagnostics.CodeAnalysis;
using NUnit.Framework;
using VkNet.Enums.SafetyEnums;
using VkNet.Tests.Infrastructure;

namespace VkNet.Tests.Categories
{
[TestFixture]
[ExcludeFromCodeCoverage]
public class GetAppImageUploadServerTest : CategoryBaseTest
{
protected override string Folder => "AppWidgets";

[Test]
public void GetAppImageUploadServer()
{
Url = "https://api.vk.com/method/appWidgets.getAppImageUploadServer";

ReadCategoryJsonPath(nameof(GetAppImageUploadServer));

var result = Api.AppWidgets.GetAppImageUploadServer(AppWidgetImageType.FiftyOnFifty);

Assert.IsNotNull(result.UploadUrl);
}
}
}
27 changes: 27 additions & 0 deletions VkNet.Tests/Categories/AppWidgets/GetAppImagesTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using NUnit.Framework;
using VkNet.Enums.SafetyEnums;
using VkNet.Tests.Infrastructure;

namespace VkNet.Tests.Categories
{
[TestFixture]
[ExcludeFromCodeCoverage]
public class GetAppImagesTest : CategoryBaseTest
{
protected override string Folder => "AppWidgets";

[Test]
public void GetAppImages()
{
Url = "https://api.vk.com/method/appWidgets.getAppImages";

ReadCategoryJsonPath(nameof(GetAppImages));

var result = Api.AppWidgets.GetAppImages(0, 10, AppWidgetImageType.FiftyOnFifty);

Assert.IsNotNull(result.Items.First().Images.First().Url);
}
}
}
26 changes: 26 additions & 0 deletions VkNet.Tests/Categories/AppWidgets/GetGroupImageUploadServerTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Diagnostics.CodeAnalysis;
using NUnit.Framework;
using VkNet.Enums.SafetyEnums;
using VkNet.Tests.Infrastructure;

namespace VkNet.Tests.Categories
{
[TestFixture]
[ExcludeFromCodeCoverage]
public class GetGroupImageUploadServerTest : CategoryBaseTest
{
protected override string Folder => "AppWidgets";

[Test]
public void GetGroupImageUploadServer()
{
Url = "https://api.vk.com/method/appWidgets.getGroupImageUploadServer";

ReadCategoryJsonPath(nameof(GetGroupImageUploadServer));

var result = Api.AppWidgets.GetGroupImageUploadServer(AppWidgetImageType.FiftyOnFifty);

Assert.IsNotNull(result.UploadUrl);
}
}
}
27 changes: 27 additions & 0 deletions VkNet.Tests/Categories/AppWidgets/GetGroupImagesTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using NUnit.Framework;
using VkNet.Enums.SafetyEnums;
using VkNet.Tests.Infrastructure;

namespace VkNet.Tests.Categories
{
[TestFixture]
[ExcludeFromCodeCoverage]
public class GetGroupImagesTest : CategoryBaseTest
{
protected override string Folder => "AppWidgets";

[Test]
public void GetGroupImages()
{
Url = "https://api.vk.com/method/appWidgets.getGroupImages";

ReadCategoryJsonPath(nameof(GetGroupImages));

var result = Api.AppWidgets.GetGroupImages(0, 10, AppWidgetImageType.FiftyOnFifty);

Assert.IsNotNull(result.Items.First().Images.First().Url);
}
}
}
27 changes: 27 additions & 0 deletions VkNet.Tests/Categories/AppWidgets/GetImagesByIdTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using NUnit.Framework;
using VkNet.Tests.Infrastructure;

namespace VkNet.Tests.Categories
{
[TestFixture]
[ExcludeFromCodeCoverage]
public class GetImagesByIdTest : CategoryBaseTest
{
protected override string Folder => "AppWidgets";

[Test]
public void GetAppImages()
{
Url = "https://api.vk.com/method/appWidgets.getImagesById";

ReadCategoryJsonPath(nameof(GetAppImages));

var result = Api.AppWidgets.GetImagesById("7309583_1192027");

Assert.IsNotNull(result);
Assert.AreEqual("7309583_1192027", result.First().Id);
}
}
}
28 changes: 28 additions & 0 deletions VkNet.Tests/Categories/AppWidgets/SaveAppImageTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using NUnit.Framework;
using VkNet.Tests.Infrastructure;

namespace VkNet.Tests.Categories
{
[TestFixture]
[ExcludeFromCodeCoverage]
public class SaveAppImageTest : CategoryBaseTest
{
protected override string Folder => "AppWidgets";

[Test]
public void SaveAppImage()
{
Url = "https://api.vk.com/method/appWidgets.saveAppImage";

ReadCategoryJsonPath(nameof(SaveAppImage));

var result = Api.AppWidgets.SaveAppImage(
"0f009dbdd6154c88b8",
"eyJvaWQiOjczMDk1ODMsInR5cGUiOjUsInBob3RvIjp7InBob3RvIjoiMjRkNmQwOWU1ZXgiLCJzaXplcyI6W1siYSIsMjA2NzIwNTg5LCI1YmYxOCIsInJ2a3JxRWRsR0tVIiw1MCw1MF0sWyJiIiwyMDY3MjA1ODksIjViZjE5IiwiYnE2VXhhakJaUFEiLDEwMCwxMDBdLFsiYyIsMjA2NzIwNTg5LCI1YmYxYSIsImI5eTlEalUtTVR3IiwxNTAsMTUwXV0sImtpZCI6IjhlMDkzZjYxOGQyY2M5MzJiMDU5YmRlYTViNjVhYmNhIiwiZGVidWciOiJ4Y2MiLCJ1cmxzIjpbInYyMDY3MjA1ODlcLzViZjE4XC9ydmtycUVkbEdLVS5qcGciLCJ2MjA2NzIwNTg5XC81YmYxOVwvYnE2VXhhakJaUFEuanBnIiwidjIwNjcyMDU4OVwvNWJmMWFcL2I5eTlEalUtTVR3LmpwZyJdfSwiYndhY3QiOiJhcHBfd2lkZ2V0X2ltYWdlIiwic2VydmVyIjoyMDY3MjAsIm1pZCI6MCwiX3NpZyI6ImNhMjI3ZWZlY2MxMjhjMzgxNTYzZjBjOGQ4YTM4ZTJlIn0");

Assert.IsNotNull(result.Images.First().Url);
}
}
}
28 changes: 28 additions & 0 deletions VkNet.Tests/Categories/AppWidgets/SaveGroupImageTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using NUnit.Framework;
using VkNet.Tests.Infrastructure;

namespace VkNet.Tests.Categories
{
[TestFixture]
[ExcludeFromCodeCoverage]
public class SaveGroupImageTest : CategoryBaseTest
{
protected override string Folder => "AppWidgets";

[Test]
public void SaveGroupImage()
{
Url = "https://api.vk.com/method/appWidgets.saveGroupImage";

ReadCategoryJsonPath(nameof(SaveGroupImage));

var result = Api.AppWidgets.SaveGroupImage(
"0f009dbdd6154c88b8",
"eyJvaWQiOjczMDk1ODMsInR5cGUiOjUsInBob3RvIjp7InBob3RvIjoiMjRkNmQwOWU1ZXgiLCJzaXplcyI6W1siYSIsMjA2NzIwNTg5LCI1YmYxOCIsInJ2a3JxRWRsR0tVIiw1MCw1MF0sWyJiIiwyMDY3MjA1ODksIjViZjE5IiwiYnE2VXhhakJaUFEiLDEwMCwxMDBdLFsiYyIsMjA2NzIwNTg5LCI1YmYxYSIsImI5eTlEalUtTVR3IiwxNTAsMTUwXV0sImtpZCI6IjhlMDkzZjYxOGQyY2M5MzJiMDU5YmRlYTViNjVhYmNhIiwiZGVidWciOiJ4Y2MiLCJ1cmxzIjpbInYyMDY3MjA1ODlcLzViZjE4XC9ydmtycUVkbEdLVS5qcGciLCJ2MjA2NzIwNTg5XC81YmYxOVwvYnE2VXhhakJaUFEuanBnIiwidjIwNjcyMDU4OVwvNWJmMWFcL2I5eTlEalUtTVR3LmpwZyJdfSwiYndhY3QiOiJhcHBfd2lkZ2V0X2ltYWdlIiwic2VydmVyIjoyMDY3MjAsIm1pZCI6MCwiX3NpZyI6ImNhMjI3ZWZlY2MxMjhjMzgxNTYzZjBjOGQ4YTM4ZTJlIn0");

Assert.IsNotNull(result.Images.First().Url);
}
}
}
26 changes: 26 additions & 0 deletions VkNet.Tests/Categories/AppWidgets/Update.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Diagnostics.CodeAnalysis;
using NUnit.Framework;
using VkNet.Enums.SafetyEnums;
using VkNet.Tests.Infrastructure;

namespace VkNet.Tests.Categories
{
[TestFixture]
[ExcludeFromCodeCoverage]
public class Update : CategoryBaseTest
{
protected override string Folder => "AppWidgets";

[Test]
public void EnableOnline()
{
Url = "https://api.vk.com/method/appWidgets.update";

ReadJsonFile(JsonPaths.True);

var result = Api.AppWidgets.Update("string", AppWidgetType.Donation);

Assert.IsTrue(result);
}
}
}
25 changes: 25 additions & 0 deletions VkNet.Tests/Enum/SafetyEnums/SafetyEnumTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -836,5 +836,30 @@ public void MarketItemButtonTitleTest()
Assert.That(MarketItemButtonTitle.FromJsonString("Купить билет"), Is.EqualTo(MarketItemButtonTitle.BuyATicket));
Assert.That(MarketItemButtonTitle.FromJsonString("Перейти в магазин"), Is.EqualTo(MarketItemButtonTitle.GoToTheStore));
}

[Test]
public void AppWidgetTypeTest()
{
// get test
Assert.That(AppWidgetType.Donation.ToString(), Is.EqualTo("donation"));
Assert.That(AppWidgetType.List.ToString(), Is.EqualTo("list"));
Assert.That(AppWidgetType.Match.ToString(), Is.EqualTo("match"));
Assert.That(AppWidgetType.Matches.ToString(), Is.EqualTo("matches"));
Assert.That(AppWidgetType.Table.ToString(), Is.EqualTo("table"));
Assert.That(AppWidgetType.Text.ToString(), Is.EqualTo("text"));
Assert.That(AppWidgetType.Tiles.ToString(), Is.EqualTo("tiles"));
Assert.That(AppWidgetType.CompactList.ToString(), Is.EqualTo("compact_list"));
Assert.That(AppWidgetType.CoverList.ToString(), Is.EqualTo("cover_list"));
// parse test
Assert.That(AppWidgetType.FromJsonString("donation"), Is.EqualTo(AppWidgetType.Donation));
Assert.That(AppWidgetType.FromJsonString("list"), Is.EqualTo(AppWidgetType.List));
Assert.That(AppWidgetType.FromJsonString("match"), Is.EqualTo(AppWidgetType.Match));
Assert.That(AppWidgetType.FromJsonString("matches"), Is.EqualTo(AppWidgetType.Matches));
Assert.That(AppWidgetType.FromJsonString("table"), Is.EqualTo(AppWidgetType.Table));
Assert.That(AppWidgetType.FromJsonString("text"), Is.EqualTo(AppWidgetType.Text));
Assert.That(AppWidgetType.FromJsonString("tiles"), Is.EqualTo(AppWidgetType.Tiles));
Assert.That(AppWidgetType.FromJsonString("compact_list"), Is.EqualTo(AppWidgetType.CompactList));
Assert.That(AppWidgetType.FromJsonString("cover_list"), Is.EqualTo(AppWidgetType.CoverList));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"response": {
"upload_url": "some_url"
}
}
112 changes: 112 additions & 0 deletions VkNet.Tests/TestData/Categories/AppWidgets/GetAppImages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"response": {
"count": 5,
"items": [
{
"id": "7309583_1192027",
"type": "50x50",
"images": [
{
"url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
"width": 50,
"height": 50
},
{
"url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
"width": 100,
"height": 100
},
{
"url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
"width": 150,
"height": 150
}
]
},
{
"id": "7309583_1192042",
"type": "50x50",
"images": [
{
"url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
"width": 50,
"height": 50
},
{
"url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
"width": 100,
"height": 100
},
{
"url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
"width": 150,
"height": 150
}
]
},
{
"id": "7309583_1192047",
"type": "50x50",
"images": [
{
"url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
"width": 50,
"height": 50
},
{
"url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
"width": 100,
"height": 100
},
{
"url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
"width": 150,
"height": 150
}
]
},
{
"id": "7309583_1192053",
"type": "50x50",
"images": [
{
"url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
"width": 50,
"height": 50
},
{
"url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
"width": 100,
"height": 100
},
{
"url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
"width": 150,
"height": 150
}
]
},
{
"id": "7309583_1192090",
"type": "50x50",
"images": [
{
"url": "https://sun9-52.userapi.com/c206720/v206720589/5bf18/rvkrqEdlGKU.jpg",
"width": 50,
"height": 50
},
{
"url": "https://sun9-46.userapi.com/c206720/v206720589/5bf19/bq6UxajBZPQ.jpg",
"width": 100,
"height": 100
},
{
"url": "https://sun9-55.userapi.com/c206720/v206720589/5bf1a/b9y9DjU-MTw.jpg",
"width": 150,
"height": 150
}
]
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"response": {
"upload_url": "some_url"
}
}
Loading

0 comments on commit 2606596

Please sign in to comment.