private IEnumerable <IPageableContainer> Page(IPagingSettings settings, string url, Type type, int maxResultsPerPage)
        {
            if (settings.Page.HasValue || settings.PerPage.HasValue)
            {
                var requestData = RequestSettingsHelper.GetPopulatedProperties(settings);
                return(PageRequest(url, requestData, type));
            }

            var  results = new List <IPageableContainer>();
            bool cont    = true;
            int  page    = 1;

            while (cont)
            {
                settings.Page    = page;
                settings.PerPage = maxResultsPerPage;
                var requestData = RequestSettingsHelper.GetPopulatedProperties(settings);
                var newResults  = PageRequest(url, requestData, type);
                if (newResults.Any())
                {
                    results.AddRange(newResults);
                }
                if (newResults.Count() < maxResultsPerPage)
                {
                    cont = false;
                }
                page++;
            }
            return(results);
        }
        public void BulkRecipientResponseSettingsAreProcessed()
        {
            var input = new BulkRecipientSettings()
            {
                Contacts = new List <Contact>
                {
                    new Contact()
                    {
                        FirstName = "First",
                        LastName  = "Last",
                        Email     = "email"
                    },
                    new Contact()
                    {
                        FirstName = "First2",
                        LastName  = "Last2",
                        Email     = "email2"
                    }
                }
            };
            var result = RequestSettingsHelper.GetPopulatedProperties(input);

            Assert.AreEqual("First", ((List <RequestData>)result["contacts"])[0]["first_name"]);
            Assert.AreEqual("Last", ((List <RequestData>)result["contacts"])[0]["last_name"]);
            Assert.AreEqual("email", ((List <RequestData>)result["contacts"])[0]["email"]);
            Assert.AreEqual("First2", ((List <RequestData>)result["contacts"])[1]["first_name"]);
            Assert.AreEqual("Last2", ((List <RequestData>)result["contacts"])[1]["last_name"]);
            Assert.AreEqual("email2", ((List <RequestData>)result["contacts"])[1]["email"]);
        }
Esempio n. 3
0
        public void ObjectPropertiesAreProcessed()
        {
            var input = new LotsOfProperties()
            {
                Time1      = new DateTime(2016, 5, 1, 12, 30, 18, DateTimeKind.Utc),
                String1    = "A string",
                Int1       = 1234,
                Long1      = 3216549874654984,
                EnumCamel1 = GetSurveyListSettings.SortByOption.NumResponses,
                EnumCaps1  = GetSurveyListSettings.SortOrderOption.DESC
            };
            var result = RequestSettingsHelper.GetPopulatedProperties(input);

            Assert.AreEqual("2016-05-01T12:30:18", result["time_1"]);
            Assert.AreEqual("A string", result["string_1"]);
            Assert.AreEqual(1234, result["int_1"]);
            Assert.AreEqual("num_responses", result["enum_camel_1"]);
            Assert.AreEqual("DESC", result["enum_caps_1"]);
            Assert.AreEqual(6, result.Count);
        }
Esempio n. 4
0
        public void ObjectPropertiesAreProcessed()
        {
            var input = new LotsOfProperties()
            {
                Time1      = new DateTime(2016, 5, 1, 12, 30, 18, DateTimeKind.Utc),
                String1    = "A string",
                Int1       = 1234,
                Long1      = 3216549874654984,
                EnumCamel1 = GetSurveyListSettings.SortByOption.NumResponses,
                EnumCaps1  = GetSurveyListSettings.SortOrderOption.DESC,
                ListTime1  = new List <DateTime> {
                    new DateTime(2015, 4, 2, 10, 19, 12, DateTimeKind.Utc)
                },
                ListString1 = new List <string> {
                    "asdf", "ghjk", "qwer"
                },
                ListInt1 = new List <int> {
                    1, 5, 0, 94
                },
                ListLong1 = new List <long> {
                    42, 918274828787344, 9827, 5219258, 51928375123857
                }
            };
            var result = RequestSettingsHelper.GetPopulatedProperties(input);

            Assert.AreEqual("2016-05-01T12:30:18", result["time_1"]);
            Assert.AreEqual("A string", result["string_1"]);
            Assert.AreEqual(1234, result["int_1"]);
            Assert.AreEqual("3216549874654984", result["long_1"]);
            Assert.AreEqual("num_responses", result["enum_camel_1"]);
            Assert.AreEqual("DESC", result["enum_caps_1"]);
            Assert.AreEqual("2015-04-02T10:19:12", ((List <string>)result["list_time_1"]).First());
            Assert.AreEqual("qwer", ((List <string>)result["list_string_1"]).Last());
            Assert.AreEqual(94, ((List <int>)result["list_int_1"]).Last());
            Assert.AreEqual("918274828787344", ((List <string>)result["list_long_1"]).Skip(1).First());
            Assert.AreEqual(10, result.Count);
        }