Пример #1
0
        public void UpdateAllTest()
        {
            // Create empty criteria.

            var campaign = CreateTestCampaign(1, CampaignCategory.Employer);

            _campaignsCommand.CreateCampaign(campaign);
            AssertCriteria(new OrganisationEmployerSearchCriteria(), _campaignsQuery.GetCriteria(campaign.Id));

            // Update with non-empty criteria.

            var newCriteria = new OrganisationEmployerSearchCriteria
            {
                Employers               = false,
                Recruiters              = false,
                VerifiedOrganisations   = false,
                UnverifiedOrganisations = false,
                IndustryIds             = new [] { Guid.NewGuid() },
                MinimumLogins           = 10,
                MaximumLogins           = 20,
            };

            _campaignsCommand.UpdateCriteria(campaign.Id, newCriteria);

            // Should not be empty.

            AssertCriteria(newCriteria, _campaignsQuery.GetCriteria(campaign.Id));
        }
Пример #2
0
        public void TestEmployersRecruitersCriteria()
        {
            var criteria = new OrganisationEmployerSearchCriteria();

            // Create some employers and recruiters.

            var employers  = CreateEmployers(0, 6, EmployerSubRole.Employer);
            var recruiters = CreateEmployers(6, 8, EmployerSubRole.Recruiter);

            // Default criteria should return everyone.

            TestSearch(criteria, employers.Concat(recruiters));

            // Only employers.

            criteria.Employers  = true;
            criteria.Recruiters = false;
            TestSearch(criteria, employers);

            // Only recruiters.

            criteria.Employers  = false;
            criteria.Recruiters = true;
            TestSearch(criteria, recruiters);

            // Neither.

            criteria.Employers  = false;
            criteria.Recruiters = false;
            TestSearch(criteria, new Employer[0]);
        }
Пример #3
0
        public void TestUpdateIndustries()
        {
            var industry = _industriesQuery.GetIndustry("Administration");
            var criteria = new OrganisationEmployerSearchCriteria {
                IndustryIds = new[] { industry.Id }
            };

            Test(criteria, () => Select(industry));
        }
Пример #4
0
        public void TestUpdateMultipleIndustries()
        {
            var industry1 = _industriesQuery.GetIndustry("Administration");
            var industry2 = _industriesQuery.GetIndustry("Engineering");
            var criteria  = new OrganisationEmployerSearchCriteria {
                IndustryIds = new[] { industry1.Id, industry2.Id }
            };

            Test(criteria, () => Select(industry1, industry2));
        }
        public void TestEmployerSubstitutions()
        {
            var index    = 0;
            var criteria = new OrganisationEmployerSearchCriteria();

            // Create some employers.

            var employers = CreateEmployers(0, 6, EmployerSubRole.Employer);

            TestSearch(++index, criteria, employers);
        }
Пример #6
0
        private void AssertPageCriteria(OrganisationEmployerSearchCriteria criteria)
        {
            Assert.AreEqual(criteria.Employers, _employersCheckBox.IsChecked);
            Assert.AreEqual(criteria.Recruiters, _recruitersCheckBox.IsChecked);
            Assert.AreEqual(criteria.VerifiedOrganisations, _verifiedOrganisationsCheckBox.IsChecked);
            Assert.AreEqual(criteria.UnverifiedOrganisations, _unverifiedOrganisationsCheckBox.IsChecked);

            AssertSelected(_industriesListBox, criteria.IndustryIds);

            Assert.AreEqual(criteria.MinimumLogins == null ? string.Empty : criteria.MinimumLogins.ToString(), _minimumLoginsTextBox.Text);
            Assert.AreEqual(criteria.MaximumLogins == null ? string.Empty : criteria.MaximumLogins.ToString(), _maximumLoginsTextBox.Text);
        }
Пример #7
0
        public void TestDefaults()
        {
            // Login as administrator.

            var administrator = _administratorAccountsCommand.CreateTestAdministrator(1);
            var campaign      = CreateCampaign(1, CampaignCategory.Employer, administrator);

            LogIn(administrator);
            Get(GetEditCriteriaUrl(campaign.Id));

            var criteria = new OrganisationEmployerSearchCriteria();

            AssertPageCriteria(criteria);
            AssertSavedCriteria(criteria, campaign.Id);
        }
Пример #8
0
        public ActionResult PostEditCriteria(Guid id, OrganisationEmployerSearchCriteria employerCriteria, MemberSearchCriteria memberCriteria)
        {
            var campaign = _campaignsQuery.GetCampaign(id);

            if (campaign == null)
            {
                return(NotFound("campaign", "id", id));
            }

            var criteria = campaign.Category == CampaignCategory.Employer ? (Criteria)employerCriteria : memberCriteria;

            _campaignsCommand.UpdateCriteria(campaign.Id, criteria);

            return(RedirectToRoute(CampaignsRoutes.EditCriteria, new { id }));
        }
        public void TestOrganisationalUnitCriteria()
        {
            var index = 0;

            // Create some organisations.

            var administrator = _administratorAccountsCommand.CreateTestAdministrator(1);
            var organisation0 = CreateOrganisation(0, false, administrator);
            var organisation1 = CreateOrganisation(1, false, administrator);
            var organisation2 = CreateOrganisation(2, true, administrator);
            var organisation3 = CreateOrganisation(3, true, administrator);
            var organisation4 = CreateOrganisation(4, true, administrator);

            // Create some employers.

            var employers0 = CreateEmployers(0, 6, organisation0);
            var employers1 = CreateEmployers(6, 8, organisation1);
            var employers2 = CreateEmployers(14, 4, organisation2);
            var employers3 = CreateEmployers(18, 2, organisation3);
            var employers4 = CreateEmployers(20, 5, organisation4);

            // Empty criteria should return everyone.

            var criteria = new OrganisationEmployerSearchCriteria();

            TestSearch(++index, criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers3).Concat(employers4));

            // Unverified.

            criteria = new OrganisationEmployerSearchCriteria {
                VerifiedOrganisations = false, UnverifiedOrganisations = true
            };
            TestSearch(++index, criteria, employers0.Concat(employers1));

            // Verified.

            criteria = new OrganisationEmployerSearchCriteria {
                VerifiedOrganisations = true, UnverifiedOrganisations = false
            };
            TestSearch(++index, criteria, employers2.Concat(employers3).Concat(employers4));

            // Neither.

            criteria = new OrganisationEmployerSearchCriteria {
                VerifiedOrganisations = false, UnverifiedOrganisations = false
            };
            TestSearch(++index, criteria, new Employer[0]);
        }
Пример #10
0
        public void TestDefaultCriteria()
        {
            var criteria = new OrganisationEmployerSearchCriteria();

            // No employers.

            TestSearch(criteria, new Employer[0]);

            // Create some employers.

            var employers = CreateEmployers(0, 6, EmployerSubRole.Employer);

            // Default criteria should return everyone.

            TestSearch(criteria, employers);
        }
Пример #11
0
        public void UpdateIndustriesTest()
        {
            // Create empty criteria.

            var campaign = CreateTestCampaign(1, CampaignCategory.Employer);

            // 1 industry.

            var industries  = new[] { Guid.NewGuid() };
            var newCriteria = new OrganisationEmployerSearchCriteria {
                IndustryIds = industries
            };

            _campaignsCommand.UpdateCriteria(campaign.Id, newCriteria);
            var criteria = (OrganisationEmployerSearchCriteria)_campaignsQuery.GetCriteria(campaign.Id);

            AssertIndustries(industries, criteria.IndustryIds);

            // 2 industries.

            industries  = new[] { Guid.NewGuid(), Guid.NewGuid() };
            newCriteria = new OrganisationEmployerSearchCriteria {
                IndustryIds = industries
            };
            _campaignsCommand.UpdateCriteria(campaign.Id, newCriteria);
            criteria = (OrganisationEmployerSearchCriteria)_campaignsQuery.GetCriteria(campaign.Id);
            AssertIndustries(industries, criteria.IndustryIds);

            // 0 industries.

            industries  = new Guid[0];
            newCriteria = new OrganisationEmployerSearchCriteria {
                IndustryIds = industries
            };
            _campaignsCommand.UpdateCriteria(campaign.Id, newCriteria);
            Assert.IsInstanceOfType(_campaignsQuery.GetCriteria(campaign.Id), typeof(OrganisationEmployerSearchCriteria));

            // Lots of industries.

            industries  = new[] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
            newCriteria = new OrganisationEmployerSearchCriteria {
                IndustryIds = industries
            };
            _campaignsCommand.UpdateCriteria(campaign.Id, newCriteria);
            criteria = (OrganisationEmployerSearchCriteria)_campaignsQuery.GetCriteria(campaign.Id);
            AssertIndustries(industries, criteria.IndustryIds);
        }
Пример #12
0
        public void UpdateIndustriesTest()
        {
            // Create empty criteria.

            var campaign = CreateTestCampaign(1, CampaignCategory.Employer);

            _campaignsCommand.CreateCampaign(campaign);

            // 1 industry.

            var industries  = new[] { Guid.NewGuid() };
            var newCriteria = new OrganisationEmployerSearchCriteria {
                IndustryIds = industries
            };

            _campaignsCommand.UpdateCriteria(campaign.Id, newCriteria);
            AssertCriteria(newCriteria, _campaignsQuery.GetCriteria(campaign.Id));

            // 2 industries.

            industries  = new[] { Guid.NewGuid(), Guid.NewGuid() };
            newCriteria = new OrganisationEmployerSearchCriteria {
                IndustryIds = industries
            };
            _campaignsCommand.UpdateCriteria(campaign.Id, newCriteria);
            AssertCriteria(newCriteria, _campaignsQuery.GetCriteria(campaign.Id));

            // 0 industries.

            industries  = new Guid[0];
            newCriteria = new OrganisationEmployerSearchCriteria {
                IndustryIds = industries
            };
            _campaignsCommand.UpdateCriteria(campaign.Id, newCriteria);
            AssertCriteria(newCriteria, _campaignsQuery.GetCriteria(campaign.Id));

            // Lots of industries.

            industries  = new[] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
            newCriteria = new OrganisationEmployerSearchCriteria {
                IndustryIds = industries
            };
            _campaignsCommand.UpdateCriteria(campaign.Id, newCriteria);
            AssertCriteria(newCriteria, _campaignsQuery.GetCriteria(campaign.Id));
        }
Пример #13
0
        public void UpdateEmptyWithEmptyCriteriaTest()
        {
            // Create empty criteria.

            var campaign = CreateTestCampaign(1, CampaignCategory.Employer);

            AssertCriterias(campaign);

            // Update with empty criteria.

            var newCriteria = new OrganisationEmployerSearchCriteria();

            _campaignsCommand.UpdateCriteria(campaign.Id, newCriteria);

            // Should still be empty.

            AssertCriterias(campaign);
        }
Пример #14
0
        public void UpdateEmptyWithNonEmptyCriteriaSet()
        {
            // Create empty criteria.

            var campaign = CreateTestCampaign(1, CampaignCategory.Employer);

            _campaignsCommand.CreateCampaign(campaign);
            AssertCriteria(new OrganisationEmployerSearchCriteria(), _campaignsQuery.GetCriteria(campaign.Id));

            // Update with non-empty criteria.

            var newCriteria = new OrganisationEmployerSearchCriteria();

            newCriteria.IndustryIds.Add(Guid.NewGuid());
            _campaignsCommand.UpdateCriteria(campaign.Id, newCriteria);

            // Should not be empty.

            AssertCriteria(newCriteria, _campaignsQuery.GetCriteria(campaign.Id));
        }
Пример #15
0
        private void Test(OrganisationEmployerSearchCriteria expectedCriteria, params Action[] updates)
        {
            // Login as administrator.

            var administrator = _administratorAccountsCommand.CreateTestAdministrator(1);
            var campaign      = CreateCampaign(1, CampaignCategory.Employer, administrator);

            LogIn(administrator);
            Get(GetEditCriteriaUrl(campaign.Id));

            // Update the page.

            foreach (var update in updates)
            {
                update();
            }
            _saveButton.Click();

            AssertPageCriteria(expectedCriteria);
            AssertSavedCriteria(expectedCriteria, campaign.Id);
        }
Пример #16
0
        public void UpdateNonEmptyWithEmptyCriteriaSet()
        {
            // Create empty criteria.

            var campaign = CreateTestCampaign(1, CampaignCategory.Employer);

            // Update with non-empty criteria.

            var newCriteria = new OrganisationEmployerSearchCriteria();

            newCriteria.IndustryIds.Add(Guid.NewGuid());
            _campaignsCommand.UpdateCriteria(campaign.Id, newCriteria);

            // Update with empty criteria.

            newCriteria = new OrganisationEmployerSearchCriteria();
            _campaignsCommand.UpdateCriteria(campaign.Id, newCriteria);
            var criteria = _campaignsQuery.GetCriteria(campaign.Id);

            Assert.AreEqual(new OrganisationEmployerSearchCriteria(), criteria);
        }
Пример #17
0
        private static void AssertCriteria(OrganisationEmployerSearchCriteria expectedCriteria, Criteria criteria)
        {
            Assert.IsInstanceOfType(criteria, typeof(OrganisationEmployerSearchCriteria));
            var organisationCriteria = (OrganisationEmployerSearchCriteria)criteria;

            Assert.AreEqual(expectedCriteria.Employers, organisationCriteria.Employers);
            Assert.AreEqual(expectedCriteria.Recruiters, organisationCriteria.Recruiters);
            Assert.AreEqual(expectedCriteria.MaximumLogins, organisationCriteria.MaximumLogins);
            Assert.AreEqual(expectedCriteria.MinimumLogins, organisationCriteria.MinimumLogins);
            Assert.AreEqual(expectedCriteria.VerifiedOrganisations, organisationCriteria.VerifiedOrganisations);
            Assert.AreEqual(expectedCriteria.UnverifiedOrganisations, organisationCriteria.UnverifiedOrganisations);

            Assert.AreEqual(expectedCriteria.IndustryIds.Count, organisationCriteria.IndustryIds.Count);
            var expectedEnum = expectedCriteria.IndustryIds.GetEnumerator();
            var industryEnum = organisationCriteria.IndustryIds.GetEnumerator();

            while (expectedEnum.MoveNext() && industryEnum.MoveNext())
            {
                Assert.AreEqual(expectedEnum.Current, industryEnum.Current);
            }
        }
Пример #18
0
 private void AssertSavedCriteria(OrganisationEmployerSearchCriteria expectedCriteria, Guid campaignId)
 {
     Assert.AreEqual(expectedCriteria, _campaignsQuery.GetCriteria(campaignId));
 }
Пример #19
0
        public void TestCombinationCriteria()
        {
            var industries = GetIndustries();

            // Create some organisations.

            var administrator = _administratorAccountsCommand.CreateTestAdministrator(1);
            var organisation0 = CreateOrganisation(0, false, administrator.Id);
            var organisation1 = CreateOrganisation(1, true, administrator.Id);

            // Create some employers.

            var employers0 = CreateEmployers(0, 1, EmployerSubRole.Employer);
            var employers1 = CreateEmployers(1, 2, EmployerSubRole.Recruiter);
            var employers2 = CreateEmployers(3, 3, industries[0]);
            var employers3 = CreateEmployers(6, 4, industries[1]);
            var employers4 = CreateEmployers(10, 5, organisation0);
            var employers5 = CreateEmployers(15, 6, organisation1);
            var employers6 = CreateEmployers(21, 7, EmployerSubRole.Employer, organisation0, industries[0]);
            var employers7 = CreateEmployers(28, 8, EmployerSubRole.Recruiter, organisation1, industries[1]);

            // Everyone.

            var criteria = new OrganisationEmployerSearchCriteria();

            TestSearch(criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers3).Concat(employers4).Concat(employers5).Concat(employers6).Concat(employers7));

            // Employers.

            criteria.Employers  = true;
            criteria.Recruiters = false;
            TestSearch(criteria, employers0.Concat(employers2).Concat(employers3).Concat(employers4).Concat(employers5).Concat(employers6));

            // Recruiters.

            criteria.Employers  = false;
            criteria.Recruiters = true;
            TestSearch(criteria, employers1.Concat(employers7));

            // Industy 0.

            criteria = new OrganisationEmployerSearchCriteria {
                IndustryIds = new[] { industries[0].Id }
            };
            TestSearch(criteria, employers2.Concat(employers6));

            // Industy 2.

            criteria = new OrganisationEmployerSearchCriteria {
                IndustryIds = new[] { industries[1].Id }
            };
            TestSearch(criteria, employers3.Concat(employers7));

            // Unverified.

            criteria = new OrganisationEmployerSearchCriteria {
                VerifiedOrganisations = false
            };
            TestSearch(criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers3).Concat(employers4).Concat(employers6));

            // Verified.

            criteria = new OrganisationEmployerSearchCriteria {
                UnverifiedOrganisations = false
            };
            TestSearch(criteria, employers5.Concat(employers7));

            // Pick out 6.

            criteria = new OrganisationEmployerSearchCriteria {
                Recruiters = false, VerifiedOrganisations = false, IndustryIds = new[] { industries[0].Id }, MinimumLogins = 12
            };
            TestSearch(criteria, employers6);

            // Pick out 7.

            criteria = new OrganisationEmployerSearchCriteria {
                Employers = false, UnverifiedOrganisations = false, IndustryIds = new[] { industries[1].Id }, MinimumLogins = 12
            };
            TestSearch(criteria, employers7);
        }
Пример #20
0
        public void TestLoginsCriteria()
        {
            // Create some organisations.

            var administrator = _administratorAccountsCommand.CreateTestAdministrator(1);
            var organisation0 = CreateOrganisation(0, false, administrator.Id);
            var organisation1 = CreateOrganisation(1, false, administrator.Id);
            var organisation2 = CreateOrganisation(2, true, administrator.Id);
            var organisation3 = CreateOrganisation(3, true, administrator.Id);
            var organisation4 = CreateOrganisation(4, true, administrator.Id);

            // Create some employers.

            var employers0 = CreateEmployers(0, 6, organisation0);
            var employers1 = CreateEmployers(6, 8, organisation1);
            var employers2 = CreateEmployers(14, 4, organisation2);
            var employers3 = CreateEmployers(18, 2, organisation3);
            var employers4 = CreateEmployers(20, 5, organisation4);

            // Empty criteria should return everyone.

            var criteria = new OrganisationEmployerSearchCriteria();

            TestSearch(criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers3).Concat(employers4));

            // Minimum logins.

            criteria.MinimumLogins = 2;
            TestSearch(criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers3).Concat(employers4));

            criteria.MinimumLogins = 3;
            TestSearch(criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers4));

            criteria.MinimumLogins = 4;
            TestSearch(criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers4));

            criteria.MinimumLogins = 5;
            TestSearch(criteria, employers0.Concat(employers1).Concat(employers4));

            criteria.MinimumLogins = 6;
            TestSearch(criteria, employers0.Concat(employers1));

            criteria.MinimumLogins = 7;
            TestSearch(criteria, employers1);

            criteria.MinimumLogins = 8;
            TestSearch(criteria, employers1);

            criteria.MinimumLogins = 9;
            TestSearch(criteria, new Employer[0]);

            // Maximum logins.

            criteria.MinimumLogins = null;
            criteria.MaximumLogins = 9;
            TestSearch(criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers3).Concat(employers4));

            criteria.MaximumLogins = 8;
            TestSearch(criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers3).Concat(employers4));

            criteria.MaximumLogins = 7;
            TestSearch(criteria, employers0.Concat(employers2).Concat(employers3).Concat(employers4));

            criteria.MaximumLogins = 6;
            TestSearch(criteria, employers0.Concat(employers2).Concat(employers3).Concat(employers4));

            criteria.MaximumLogins = 5;
            TestSearch(criteria, employers2.Concat(employers3).Concat(employers4));

            criteria.MaximumLogins = 4;
            TestSearch(criteria, employers2.Concat(employers3));

            criteria.MaximumLogins = 3;
            TestSearch(criteria, employers3);

            criteria.MaximumLogins = 2;
            TestSearch(criteria, employers3);

            criteria.MaximumLogins = 1;
            TestSearch(criteria, new Employer[0]);

            // Both.

            criteria.MinimumLogins = 0;
            criteria.MaximumLogins = 9;
            TestSearch(criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers3).Concat(employers4));

            criteria.MinimumLogins = 1;
            criteria.MaximumLogins = 8;
            TestSearch(criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers3).Concat(employers4));

            criteria.MinimumLogins = 2;
            criteria.MaximumLogins = 7;
            TestSearch(criteria, employers0.Concat(employers2).Concat(employers3).Concat(employers4));

            criteria.MinimumLogins = 3;
            criteria.MaximumLogins = 6;
            TestSearch(criteria, employers0.Concat(employers2).Concat(employers4));

            criteria.MinimumLogins = 4;
            criteria.MaximumLogins = 5;
            TestSearch(criteria, employers2.Concat(employers4));

            criteria.MinimumLogins = 5;
            criteria.MaximumLogins = 4;
            TestSearch(criteria, new Employer[0]);
        }
        public void TestLoginsCriteria()
        {
            var index = 0;

            // Create some organisations.

            var administrator = _administratorAccountsCommand.CreateTestAdministrator(1);
            var organisation0 = CreateOrganisation(0, false, administrator);
            var organisation1 = CreateOrganisation(1, false, administrator);
            var organisation2 = CreateOrganisation(2, true, administrator);
            var organisation3 = CreateOrganisation(3, true, administrator);
            var organisation4 = CreateOrganisation(4, true, administrator);

            // Create some employers.

            var employers0 = CreateEmployers(0, 6, organisation0);
            var employers1 = CreateEmployers(6, 8, organisation1);
            var employers2 = CreateEmployers(14, 4, organisation2);
            var employers3 = CreateEmployers(18, 2, organisation3);
            var employers4 = CreateEmployers(20, 5, organisation4);

            // Empty criteria should return everyone.

            var criteria = new OrganisationEmployerSearchCriteria();

            TestSearch(++index, criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers3).Concat(employers4));

            // Minimum logins.

            criteria = new OrganisationEmployerSearchCriteria {
                MinimumLogins = 2
            };
            TestSearch(++index, criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers3).Concat(employers4));

            criteria = new OrganisationEmployerSearchCriteria {
                MinimumLogins = 3
            };
            TestSearch(++index, criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers4));

            criteria = new OrganisationEmployerSearchCriteria {
                MinimumLogins = 4
            };
            TestSearch(++index, criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers4));

            criteria = new OrganisationEmployerSearchCriteria {
                MinimumLogins = 5
            };
            TestSearch(++index, criteria, employers0.Concat(employers1).Concat(employers4));

            criteria = new OrganisationEmployerSearchCriteria {
                MinimumLogins = 6
            };
            TestSearch(++index, criteria, employers0.Concat(employers1));

            criteria = new OrganisationEmployerSearchCriteria {
                MinimumLogins = 7
            };
            TestSearch(++index, criteria, employers1);

            criteria = new OrganisationEmployerSearchCriteria {
                MinimumLogins = 8
            };
            TestSearch(++index, criteria, employers1);

            criteria = new OrganisationEmployerSearchCriteria {
                MinimumLogins = 9
            };
            TestSearch(++index, criteria, new Employer[0]);

            // Maximum logins.

            criteria = new OrganisationEmployerSearchCriteria {
                MinimumLogins = null, MaximumLogins = 9
            };
            TestSearch(++index, criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers3).Concat(employers4));

            criteria = new OrganisationEmployerSearchCriteria {
                MaximumLogins = 8
            };
            TestSearch(++index, criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers3).Concat(employers4));

            criteria = new OrganisationEmployerSearchCriteria {
                MaximumLogins = 7
            };
            TestSearch(++index, criteria, employers0.Concat(employers2).Concat(employers3).Concat(employers4));

            criteria = new OrganisationEmployerSearchCriteria {
                MaximumLogins = 6
            };
            TestSearch(++index, criteria, employers0.Concat(employers2).Concat(employers3).Concat(employers4));

            criteria = new OrganisationEmployerSearchCriteria {
                MaximumLogins = 5
            };
            TestSearch(++index, criteria, employers2.Concat(employers3).Concat(employers4));

            criteria = new OrganisationEmployerSearchCriteria {
                MaximumLogins = 4
            };
            TestSearch(++index, criteria, employers2.Concat(employers3));

            criteria = new OrganisationEmployerSearchCriteria {
                MaximumLogins = 3
            };
            TestSearch(++index, criteria, employers3);

            criteria = new OrganisationEmployerSearchCriteria {
                MaximumLogins = 2
            };
            TestSearch(++index, criteria, employers3);

            criteria = new OrganisationEmployerSearchCriteria {
                MaximumLogins = 1
            };
            TestSearch(++index, criteria, new Employer[0]);

            // Both.

            criteria = new OrganisationEmployerSearchCriteria {
                MinimumLogins = 0, MaximumLogins = 9
            };
            TestSearch(++index, criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers3).Concat(employers4));

            criteria = new OrganisationEmployerSearchCriteria {
                MinimumLogins = 1, MaximumLogins = 8
            };
            TestSearch(++index, criteria, employers0.Concat(employers1).Concat(employers2).Concat(employers3).Concat(employers4));

            criteria = new OrganisationEmployerSearchCriteria {
                MinimumLogins = 2, MaximumLogins = 7
            };
            TestSearch(++index, criteria, employers0.Concat(employers2).Concat(employers3).Concat(employers4));

            criteria = new OrganisationEmployerSearchCriteria {
                MinimumLogins = 3, MaximumLogins = 6
            };
            TestSearch(++index, criteria, employers0.Concat(employers2).Concat(employers4));

            criteria = new OrganisationEmployerSearchCriteria {
                MinimumLogins = 4, MaximumLogins = 5
            };
            TestSearch(++index, criteria, employers2.Concat(employers4));

            criteria = new OrganisationEmployerSearchCriteria {
                MinimumLogins = 5, MaximumLogins = 4
            };
            TestSearch(++index, criteria, new Employer[0]);
        }
Пример #22
0
        public void TestIndustriesCriteria()
        {
            var criteria   = new OrganisationEmployerSearchCriteria();
            var industries = GetIndustries();

            // Create some employers in one industry.

            var employers0 = CreateEmployers(0, 6, industries[0]);

            // Create some employers in another industry.

            var employers1 = CreateEmployers(6, 8, industries[1]);

            // Create some employers in both.

            var employers01 = CreateEmployers(14, 4, industries[0], industries[1]);

            // Create some employers in neither.

            var employers2 = CreateEmployers(18, 2, industries[2]);

            // Create some employers in none.

            var employers = CreateEmployers(20, 5, EmployerSubRole.Employer);

            // Default criteria should return everyone.

            TestSearch(criteria, employers0.Concat(employers1).Concat(employers01).Concat(employers2).Concat(employers));

            // Industry 0

            criteria.IndustryIds = new[] { industries[0].Id };
            TestSearch(criteria, employers0.Concat(employers01));

            // Industry 1

            criteria.IndustryIds = new[] { industries[1].Id };
            TestSearch(criteria, employers1.Concat(employers01));

            // Industry 2

            criteria.IndustryIds = new[] { industries[2].Id };
            TestSearch(criteria, employers2);

            // Industry 0 & 1

            criteria.IndustryIds = new[] { industries[0].Id, industries[1].Id };
            TestSearch(criteria, employers0.Concat(employers1).Concat(employers01));

            // Industry 0 & 2

            criteria.IndustryIds = new[] { industries[0].Id, industries[2].Id };
            TestSearch(criteria, employers0.Concat(employers01).Concat(employers2));

            // Industry 1 & 2

            criteria.IndustryIds = new[] { industries[1].Id, industries[2].Id };
            TestSearch(criteria, employers1.Concat(employers01).Concat(employers2));

            // Industry 0, 1 & 2

            criteria.IndustryIds = new[] { industries[0].Id, industries[1].Id, industries[2].Id };
            TestSearch(criteria, employers0.Concat(employers1).Concat(employers01).Concat(employers2));

            // All

            criteria.IndustryIds = industries.Select(i => i.Id).ToArray();
            TestSearch(criteria, employers0.Concat(employers1).Concat(employers01).Concat(employers2));
        }
Пример #23
0
        IList <Employer> IEmployersRepository.Search(OrganisationEmployerSearchCriteria criteria)
        {
            using (var dc = CreateContext())
            {
                // Only include enabled users.

                var employers = from e in dc.EmployerEntities
                                join u in dc.RegisteredUserEntities on e.id equals u.id
                                where (u.flags & (short)UserFlags.Disabled) == 0
                                select new { e, u };

                // Employers, recruiters?

                if (criteria.Employers && !criteria.Recruiters)
                {
                    employers = from q in employers
                                where q.e.subRole == (byte)EmployerSubRole.Employer
                                select q;
                }
                else if (!criteria.Employers && criteria.Recruiters)
                {
                    employers = from q in employers
                                where q.e.subRole == (byte)EmployerSubRole.Recruiter
                                select q;
                }

                // Industries.

                if (criteria.IndustryIds != null && criteria.IndustryIds.Count > 0)
                {
                    var industries = criteria.IndustryIds.ToArray();
                    employers = from q in employers
                                join ei in dc.EmployerIndustryEntities on q.e.id equals ei.employerId
                                where industries.Contains(ei.industryId)
                                select q;
                }

                // Organisation.

                if (criteria.VerifiedOrganisations && !criteria.UnverifiedOrganisations)
                {
                    employers = from q in employers
                                join ou in dc.OrganisationalUnitEntities on q.e.organisationId equals ou.id
                                select q;
                }
                else if (!criteria.VerifiedOrganisations && criteria.UnverifiedOrganisations)
                {
                    employers = from q in employers
                                join o in dc.OrganisationEntities on q.e.organisationId equals o.id
                                where !(from ou in dc.OrganisationalUnitEntities select ou.id).Contains(o.id)
                                select q;
                }

                // Logins.

                if (criteria.MinimumLogins != null)
                {
                    employers = from q in employers
                                where (from e in dc.EmployerEntities where e.organisationId == q.e.organisationId select e).Count() >= criteria.MinimumLogins.Value
                                select q;
                }
                if (criteria.MaximumLogins != null)
                {
                    employers = from q in employers
                                where (from e in dc.EmployerEntities where e.organisationId == q.e.organisationId select e).Count() <= criteria.MaximumLogins.Value
                                select q;
                }

                // Do the query.

                return((from e in employers.Distinct().ToList()
                        orderby e.u.emailAddress
                        select Mappings.Map(e.e, e.u, _industriesQuery)).ToList());
            }
        }