test SendActions
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using PocketSharp.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using PocketSharp.Models;
|
||||
|
||||
namespace PocketSharp.Tests
|
||||
{
|
||||
@@ -62,6 +63,31 @@ namespace PocketSharp.Tests
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public async Task AreMultipleActionsSent()
|
||||
{
|
||||
PocketItem item = await Setup();
|
||||
|
||||
bool success = await client.SendActions(new List<PocketAction>()
|
||||
{
|
||||
new PocketAction() { Action = "favorite", ID = item.ID },
|
||||
new PocketAction() { Action = "tags_add", ID = item.ID, Tags = new string[] { "new_tag", "another_tag" } },
|
||||
new PocketAction() { Action = "archive", ID = item.ID },
|
||||
new PocketAction() { Action = "tag_rename", ID = item.ID, OldTag = "social", NewTag = "not_social" }
|
||||
});
|
||||
|
||||
Assert.True(success);
|
||||
|
||||
item = await client.Get(item.ID);
|
||||
|
||||
Assert.True(item.IsFavorite);
|
||||
Assert.True(item.IsArchive);
|
||||
Assert.NotNull(item.Tags.Single<PocketTag>(tag => tag.Name == "new_tag"));
|
||||
Assert.NotNull(item.Tags.Single<PocketTag>(tag => tag.Name == "another_tag"));
|
||||
Assert.NotNull(item.Tags.Single<PocketTag>(tag => tag.Name == "not_social"));
|
||||
}
|
||||
|
||||
|
||||
private async Task<PocketItem> Setup()
|
||||
{
|
||||
PocketItem item = await client.Add(
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace PocketSharp
|
||||
/// <exception cref="PocketException"></exception>
|
||||
public async Task<bool> RenameTag(int itemID, string oldTag, string newTag, CancellationToken cancellationToken = default(CancellationToken))
|
||||
{
|
||||
return await Send(new ActionParameter()
|
||||
return await Send(new PocketAction()
|
||||
{
|
||||
Action = "tag_rename",
|
||||
ID = itemID,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using PocketSharp.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using PocketSharp.Models;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PocketSharp
|
||||
{
|
||||
@@ -203,6 +203,16 @@ namespace PocketSharp
|
||||
#endregion
|
||||
|
||||
#region modify methods
|
||||
/// <summary>
|
||||
/// Sends multiple actions in one request.
|
||||
/// See: http://getpocket.com/developer/docs/v3/modify
|
||||
/// </summary>
|
||||
/// <param name="actions">The actions.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="PocketException"></exception>
|
||||
Task<bool> SendActions(List<PocketAction> actions, CancellationToken cancellationToken = default(CancellationToken));
|
||||
|
||||
/// <summary>
|
||||
/// Archives the specified item.
|
||||
/// </summary>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<Compile Include="Components\ModifyTags.cs" />
|
||||
<Compile Include="Components\Get.cs" />
|
||||
<Compile Include="Utilities\JsonExtensions.cs" />
|
||||
<Compile Include="Models\Parameters\ActionParameter.cs" />
|
||||
<Compile Include="Models\PocketAction.cs" />
|
||||
<Compile Include="Models\Parameters\AddParameters.cs" />
|
||||
<Compile Include="Models\Parameters\ModifyParameters.cs" />
|
||||
<Compile Include="Models\Parameters\Parameters.cs" />
|
||||
|
||||
Reference in New Issue
Block a user