public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new LeadsClient(connection);

                var filters = new LeadFilters
                {
                    PageSize       = 1,
                    PageCount      = 1,
                    StartPage      = 0,
                    ArchivedStatus = ArchivedStatus.not_archived,
                };

                await client.GetAll(filters);

                Received.InOrder(async() =>
                {
                    await connection.GetAll <Lead>(
                        Arg.Is <Uri>(u => u.ToString() == "leads"),
                        Arg.Is <Dictionary <string, string> >(d => d.Count == 1 &&
                                                              d["archived_status"] == "not_archived"),
                        Arg.Is <ApiOptions>(o => o.PageSize == 1 &&
                                            o.PageCount == 1 &&
                                            o.StartPage == 0));
                });
            }
            public async Task ReturnsCorrectCountWithoutStart()
            {
                var pipedrive = Helper.GetAuthenticatedClient();

                var options = new LeadFilters
                {
                    PageSize  = 3,
                    PageCount = 1
                };

                var leads = await pipedrive.Lead.GetAll(options);

                Assert.Equal(3, leads.Count);
            }
Exemple #3
0
        public static Expression <Func <Lead, bool> > WhereFilter(LeadFilters filters)
        {
            var expr = PredicateBuilder.True <Lead>();

            if (filters.AccountManagerId.HasValue)
            {
                expr = expr.And(x => x.AccountManagerId == filters.AccountManagerId.Value);
            }

            if (filters.AccountManagerOrganizationId.HasValue)
            {
                expr = expr.And(x => x.AccountManagerOrganizationId == filters.AccountManagerOrganizationId.Value);
            }

            return(expr);
        }
            public async Task ReturnsDistinctInfosBasedOnStartPage()
            {
                var pipedrive = Helper.GetAuthenticatedClient();

                var startOptions = new LeadFilters
                {
                    PageSize  = 1,
                    PageCount = 1
                };

                var firstPage = await pipedrive.Lead.GetAll(startOptions);

                var skipStartOptions = new LeadFilters
                {
                    PageSize  = 1,
                    PageCount = 1,
                    StartPage = 1
                };

                var secondPage = await pipedrive.Lead.GetAll(skipStartOptions);

                Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
            }
Exemple #5
0
 public static IQueryable <Lead> ApplyWhereFilters(this IQueryable <Lead> entities,
                                                   LeadFilters filters)
 {
     return(entities.Where(WhereFilter(filters)));
 }