示例#1
0
        public void MultipleFiltersTest()
        {
            const int minAgeValue      = 25;
            const int maxAgeValue      = 30;
            const int minExperienceAge = 4;
            const int maxExperienceAge = 19;
            var       positions        = new List <string>
            {
                "General",
                "Doctor"
            };

            var needPositions = new PositionsApi(_conf).Get().Records.Where(x => positions.Contains(x.Name)).ToList();
            var filteredUsers = new UsersApi(_conf).GetFilteredUsers(new RequestUsersModel
            {
                WorkingExperience = new MinMaxValueRequestModel
                {
                    MinValue = minExperienceAge,
                    MaxValue = maxExperienceAge
                },
                Age = new MinMaxValueRequestModel
                {
                    MinValue = minAgeValue,
                    MaxValue = maxAgeValue
                },
                Positions = needPositions.Select(x => x.Id).ToList()
            }).Records;

            filteredUsers.ShouldSatisfyAllConditions(
                () => filteredUsers.Count.ShouldNotBe(0),
                () => filteredUsers.Select(x => x.WorkPeriodStartDate)
                .All(x => GetYearsFromToday(x.Value) <= maxExperienceAge)
                .ShouldBeTrue(),
                () => filteredUsers.Select(x => x.WorkPeriodStartDate)
                .All(x => GetYearsFromToday(x.Value) >= minExperienceAge)
                .ShouldBeTrue(),
                () => filteredUsers.Select(x => x.WorkPeriodStartDate)
                .All(x => GetYearsFromToday(x.Value) <= maxExperienceAge)
                .ShouldBeTrue(),
                () => filteredUsers.Select(x => x.WorkPeriodStartDate)
                .All(x => GetYearsFromToday(x.Value) >= minExperienceAge)
                .ShouldBeTrue(),
                () => filteredUsers.Select(x => x.Position.Name).ShouldBeSubsetOf(needPositions.Select(x => x.Name)),
                () => filteredUsers.Select(x => x.Position.Id).ShouldBeSubsetOf(needPositions.Select(x => x.Id))
                );
        }
示例#2
0
        public void FilteringByPositionsTest()
        {
            var positions = new List <string>
            {
                "General",
                "Doctor"
            };

            var needPositions = new PositionsApi(_conf).Get().Records.Where(x => positions.Contains(x.Name)).ToList();
            var filteredUsers = new UsersApi(_conf).GetFilteredUsers(new RequestUsersModel
            {
                Positions = needPositions.Select(x => x.Id).ToList()
            }).Records;

            filteredUsers.ShouldSatisfyAllConditions(
                () => filteredUsers.Count.ShouldNotBe(0),
                () => filteredUsers.Select(x => x.Position.Name).ShouldBeSubsetOf(needPositions.Select(x => x.Name)),
                () => filteredUsers.Select(x => x.Position.Id).ShouldBeSubsetOf(needPositions.Select(x => x.Id))
                );
        }