From f4f1803175c227c4cb58f247c98191aa9f667b20 Mon Sep 17 00:00:00 2001 From: David Rouyer Date: Tue, 8 Jan 2019 12:15:52 +0100 Subject: [PATCH] fix: filter by activity done --- .../Clients/ActivitiesClientTests.cs | 16 +++++++++---- .../Clients/DealsClientTests.cs | 24 ++++++++++++------- .../Clients/FilesClientTests.cs | 1 - .../Models/Request/ActivityFilters.cs | 2 +- .../Models/Request/DealActivityFilters.cs | 2 +- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/Pipedrive.net.Tests/Clients/ActivitiesClientTests.cs b/src/Pipedrive.net.Tests/Clients/ActivitiesClientTests.cs index 6fc9ed20..bcbc9146 100644 --- a/src/Pipedrive.net.Tests/Clients/ActivitiesClientTests.cs +++ b/src/Pipedrive.net.Tests/Clients/ActivitiesClientTests.cs @@ -38,6 +38,7 @@ public async Task RequestsCorrectUrl() PageSize = 1, PageCount = 1, StartPage = 0, + Done = ActivityDone.Done, }; await client.GetAll(filters); @@ -46,8 +47,9 @@ public async Task RequestsCorrectUrl() { await connection.GetAll( Arg.Is(u => u.ToString() == "activities"), - Arg.Is>(d => d.Count == 1 - && d["user_id"] == "0"), + Arg.Is>(d => d.Count == 2 + && d["user_id"] == "0" + && d["done"] == "1"), Arg.Is(o => o.PageSize == 1 && o.PageCount == 1 && o.StartPage == 0) @@ -77,6 +79,7 @@ public async Task RequestsCorrectUrl() PageSize = 1, PageCount = 1, StartPage = 0, + Done = ActivityDone.Done, }; await client.GetAllForCurrent(filters); @@ -85,7 +88,8 @@ public async Task RequestsCorrectUrl() { await connection.GetAll( Arg.Is(u => u.ToString() == "activities"), - Arg.Is>(d => d.Count == 0), + Arg.Is>(d => d.Count == 1 + && d["done"] == "1"), Arg.Is(o => o.PageSize == 1 && o.PageCount == 1 && o.StartPage == 0) @@ -115,6 +119,7 @@ public async Task RequestsCorrectUrl() PageSize = 1, PageCount = 1, StartPage = 0, + Done = ActivityDone.Done, }; await client.GetAllForUserId(123, filters); @@ -123,8 +128,9 @@ public async Task RequestsCorrectUrl() { await connection.GetAll( Arg.Is(u => u.ToString() == "activities"), - Arg.Is>(d => d.Count == 1 - && d["user_id"] == "123"), + Arg.Is>(d => d.Count == 2 + && d["user_id"] == "123" + && d["done"] == "1"), Arg.Is(o => o.PageSize == 1 && o.PageCount == 1 && o.StartPage == 0) diff --git a/src/Pipedrive.net.Tests/Clients/DealsClientTests.cs b/src/Pipedrive.net.Tests/Clients/DealsClientTests.cs index 9ba97f3d..62bf6439 100644 --- a/src/Pipedrive.net.Tests/Clients/DealsClientTests.cs +++ b/src/Pipedrive.net.Tests/Clients/DealsClientTests.cs @@ -39,6 +39,7 @@ public async Task RequestsCorrectUrl() PageSize = 1, PageCount = 1, StartPage = 0, + Status = DealStatus.lost, }; await client.GetAll(filters); @@ -47,8 +48,9 @@ public async Task RequestsCorrectUrl() { await connection.GetAll( Arg.Is(u => u.ToString() == "deals"), - Arg.Is>(d => d.Count == 1 - && d["owned_by_you"] == "0"), + Arg.Is>(d => d.Count == 2 + && d["owned_by_you"] == "0" + && d["status"] == "lost"), Arg.Is(o => o.PageSize == 1 && o.PageCount == 1 && o.StartPage == 0) @@ -78,6 +80,7 @@ public async Task RequestsCorrectUrl() PageSize = 1, PageCount = 1, StartPage = 0, + Status = DealStatus.lost, }; await client.GetAllForCurrent(filters); @@ -86,8 +89,9 @@ public async Task RequestsCorrectUrl() { await connection.GetAll( Arg.Is(u => u.ToString() == "deals"), - Arg.Is>(d => d.Count == 1 - && d["owned_by_you"] == "1"), + Arg.Is>(d => d.Count == 2 + && d["owned_by_you"] == "1" + && d["status"] == "lost"), Arg.Is(o => o.PageSize == 1 && o.PageCount == 1 && o.StartPage == 0) @@ -117,6 +121,7 @@ public async Task RequestsCorrectUrl() PageSize = 1, PageCount = 1, StartPage = 0, + Status = DealStatus.lost, }; await client.GetAllForUserId(123, filters); @@ -125,8 +130,9 @@ public async Task RequestsCorrectUrl() { await connection.GetAll( Arg.Is(u => u.ToString() == "deals"), - Arg.Is>(d => d.Count == 1 - && d["user_id"] == "123"), + Arg.Is>(d => d.Count == 2 + && d["user_id"] == "123" + && d["status"] == "lost"), Arg.Is(o => o.PageSize == 1 && o.PageCount == 1 && o.StartPage == 0) @@ -317,6 +323,7 @@ public async Task RequestsCorrectUrl() PageSize = 1, PageCount = 1, StartPage = 0, + Done = ActivityDone.Done, }; await client.GetActivities(123, filters); @@ -325,8 +332,9 @@ public async Task RequestsCorrectUrl() { await connection.GetAll( Arg.Is(u => u.ToString() == "deals/123/activities"), - Arg.Is>(d => d.Count == 1 - && d["id"] == "123"), + Arg.Is>(d => d.Count == 2 + && d["id"] == "123" + && d["done"] == "1"), Arg.Is(o => o.PageSize == 1 && o.PageCount == 1 && o.StartPage == 0) diff --git a/src/Pipedrive.net.Tests/Clients/FilesClientTests.cs b/src/Pipedrive.net.Tests/Clients/FilesClientTests.cs index 4a607519..a903e3cd 100644 --- a/src/Pipedrive.net.Tests/Clients/FilesClientTests.cs +++ b/src/Pipedrive.net.Tests/Clients/FilesClientTests.cs @@ -1,7 +1,6 @@ using NSubstitute; using System; using System.Collections.Generic; -using System.IO; using System.Threading.Tasks; using Xunit; diff --git a/src/Pipedrive.net/Models/Request/ActivityFilters.cs b/src/Pipedrive.net/Models/Request/ActivityFilters.cs index 55ac9e2e..81c2cb77 100644 --- a/src/Pipedrive.net/Models/Request/ActivityFilters.cs +++ b/src/Pipedrive.net/Models/Request/ActivityFilters.cs @@ -52,7 +52,7 @@ public IDictionary Parameters } if (Done.HasValue) { - d.Add("done", Done.Value.ToString()); + d.Add("done", ((int)Done.Value).ToString()); } return d; } diff --git a/src/Pipedrive.net/Models/Request/DealActivityFilters.cs b/src/Pipedrive.net/Models/Request/DealActivityFilters.cs index 125ea7a9..23bc8a60 100644 --- a/src/Pipedrive.net/Models/Request/DealActivityFilters.cs +++ b/src/Pipedrive.net/Models/Request/DealActivityFilters.cs @@ -29,7 +29,7 @@ public IDictionary Parameters var d = new Dictionary(); if (Done.HasValue) { - d.Add("done", Done.Value.ToString()); + d.Add("done", ((int)Done.Value).ToString()); } if (!string.IsNullOrWhiteSpace(Exclude)) {