示例#1
0
        public void SearchPetition_Paging()
        {
            var submitter = Helpers.CreateNewUser();

            var petition1 = Helpers.CreateNewPetition(submitter,
                                                      title: "First Found", startTime: DateTime.UtcNow.AddDays(-3), endTime: DateTime.UtcNow.AddDays(1));

            var petition2 = Helpers.CreateNewPetition(submitter,
                                                      title: "Second Found", startTime: DateTime.UtcNow.AddDays(-2), endTime: DateTime.UtcNow.AddDays(1));

            var petition3 = Helpers.CreateNewPetition(submitter,
                                                      title: "Third Found", startTime: DateTime.UtcNow.AddDays(-1), endTime: DateTime.UtcNow.AddDays(1));

            try
            {
                var service = new PetitionService();
                var results = service.Search(null, "Found", pageNumber: 2, pageItemCount: 1);


                Assert.AreEqual(1, results.Count);
                Assert.AreEqual("Second Found", results[0].Title);
            }
            finally
            {
                Helpers.DeleteUser(submitter);
            }
        }
示例#2
0
        public void SearchPetition_Active_OnlyActive()
        {
            var user = Helpers.CreateNewUser();

            var activePetitionId = Helpers.CreateNewPetition(user, "Active Petition",
                                                             startTime: DateTime.UtcNow.AddDays(-1),
                                                             endTime: DateTime.UtcNow.AddDays(1));

            var inactivePetitionId = Helpers.CreateNewPetition(user, "Inactive Petition",
                                                               startTime: DateTime.UtcNow.AddDays(5),
                                                               endTime: DateTime.UtcNow.AddDays(10));

            try
            {
                var service = new PetitionService();
                var actual  = service.Search(null, null, null, true);

                Assert.AreEqual(1, actual.Count);
                Assert.AreEqual("Active Petition", actual[0].Title);
            }
            finally
            {
                Helpers.DeleteUser(user);
            }
        }
示例#3
0
        public void SearchPetition_Successful_OnlySuccessfull()
        {
            var user         = Helpers.CreateNewUser();
            var signingUsers = new List <string>();

            var successfulPetition = Helpers.CreateNewPetition(user, "Successful Petition",
                                                               startTime: DateTime.UtcNow.AddDays(-1),
                                                               endTime: DateTime.UtcNow.AddDays(1),
                                                               targetCount: 1);

            signingUsers.AddRange(Helpers.SignPetition(successfulPetition, 1));

            var unSuccesfulPetition = Helpers.CreateNewPetition(user, "Unsuccessful Petition",
                                                                startTime: DateTime.UtcNow.AddDays(-2),
                                                                endTime: DateTime.UtcNow.AddDays(-1),
                                                                targetCount: 5);

            signingUsers.AddRange(Helpers.SignPetition(unSuccesfulPetition, 2));

            try
            {
                var service = new PetitionService();
                var actual  = service.Search(null, null, null);

                Assert.AreEqual(1, actual.Count);
                Assert.AreEqual("Successful Petition", actual[0].Title);
            }
            finally
            {
                Helpers.DeleteUsers(signingUsers);
                Helpers.DeleteUser(user);
            }
        }
示例#4
0
        public ActionResult FilterPetitions(int?ParliamentID = null, int page = 1, string sort = "Title", string sortDir = "Ascending", string title = "")
        {
            var service = new PetitionService();
            var model   = service.Search(null, title, null, pageItemCount: 1000, parliamentId: ParliamentID);

            return(PartialView("_SearchResult", model));
        }