Exemplo n.º 1
0
            public async Task RequestsCorrectUrl()
            {
                var connection = Substitute.For <IApiConnection>();
                var client     = new PipelinesClient(connection);

                var filters = new PipelineDealFilters
                {
                    PageSize  = 1,
                    PageCount = 1,
                    StartPage = 0,
                };

                await client.GetDeals(123, filters);

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

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

                var pipelineDeals = await pipedrive.Pipeline.GetDeals(1, options);

                Assert.Equal(3, pipelineDeals.Count);
            }
            public async Task ReturnsDistinctInfosBasedOnStartPage()
            {
                var pipedrive = Helper.GetAuthenticatedClient();

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

                var firstPage = await pipedrive.Pipeline.GetDeals(1, startOptions);

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

                var secondPage = await pipedrive.Pipeline.GetDeals(1, skipStartOptions);

                Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
            }