Ejemplo n.º 1
0
        public void AbsenceDaysCannotBookTests(AbsenceRange absenceRange, WorkingPattern workingPattern, IEnumerable <PublicHoliday> publicHolidays, IEnumerable <AbsenceDay> alreadyBookedAbsenceDays, IEnumerable <INotAbsenceDay> expectedAbsenceDays)
        {
            // Arrange
            _mockHRDataService.Setup(m => m.RetrievePublicHolidays(It.IsAny <Int32>(), It.IsAny <Int32>(), It.IsAny <Expression <Func <PublicHoliday, bool> > >(), It.IsAny <List <OrderBy> >(), It.IsAny <Paging>())).Returns(PagedResult <PublicHoliday> .Create(publicHolidays, 1, publicHolidays.Count(), 1, publicHolidays.Count()));
            _mockHRDataService.Setup(m => m.RetrieveAbsenceRangeBookedAbsenceDays(It.IsAny <AbsenceRange>()))
            .Returns(alreadyBookedAbsenceDays);
            // Act
            var actualAbsenceDays = _hrBusinessService.RetrieveCannotBeBookedDays(absenceRange, workingPattern);

            // Assert
            actualAbsenceDays.ShouldBeEquivalentTo(expectedAbsenceDays);
            _mockHRDataService.Verify(m => m.RetrievePublicHolidays(It.IsAny <Int32>(), It.IsAny <Int32>(), It.IsAny <Expression <Func <PublicHoliday, bool> > >(), It.IsAny <List <OrderBy> >(), It.IsAny <Paging>()), Times.Once);
            _mockHRDataService.Verify(m => m.RetrieveAbsenceRangeBookedAbsenceDays(It.IsAny <AbsenceRange>()), Times.Once);
        }
Ejemplo n.º 2
0
        public double?CalculateProRataEntitlement(AbsencePolicyEntitlement absencePolicyEntitlement, WorkingPattern absencePolicyWorkingPattern, DateTime periodStartDate, DateTime periodEndDate, DateTime employmentStartDate)
        {
            if (absencePolicyEntitlement == null || absencePolicyWorkingPattern == null)
            {
                return(null);
            }

            if (absencePolicyEntitlement.Entitlement == 0)
            {
                return(0);
            }

            if (employmentStartDate == periodStartDate)
            {
                return(absencePolicyEntitlement.Entitlement);
            }

            var entitlementForWeek = (absencePolicyEntitlement.Entitlement * 7) / (absencePolicyEntitlement.EndDate.Value - absencePolicyEntitlement.StartDate.Value).TotalDays;
            var weekLeft           = ((periodEndDate - employmentStartDate).TotalDays) / 7;
            var entitlement        = (entitlementForWeek * weekLeft);

            // round to nearest half day
            return(Math.Round(entitlement * 2, MidpointRounding.AwayFromZero) / 2);
        }
        public async Task OneTimeSetUp()
        {
            // Get settings from appsettings
            IConfigurationRoot configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build();

            this.AppSettings = configuration.Get <AppSettings>();

            this.ServiceBus = new ServiceBusSupport(new TopicClientFactory(), this.AppSettings);

            // Send wake up job profile
            this.WakeUpJobProfile = this.CommonAction.GetResource <JobProfileContentType>("JobProfileTemplate");
            this.WakeUpJobProfile.JobProfileId  = Guid.NewGuid().ToString();
            this.WakeUpJobProfile.CanonicalName = this.CommonAction.RandomString(10).ToLowerInvariant();
            var jobProfileMessageBody = this.CommonAction.ConvertObjectToByteArray(this.WakeUpJobProfile);
            var message = new MessageFactory().Create(this.WakeUpJobProfile.JobProfileId, jobProfileMessageBody, "Published", "JobProfile");

            await this.ServiceBus.SendMessage(message).ConfigureAwait(false);

            await Task.Delay(TimeSpan.FromMinutes(this.AppSettings.DeploymentWaitInMinutes)).ConfigureAwait(true);

            // Generate a test job profile
            this.JobProfile = this.CommonAction.GetResource <JobProfileContentType>("JobProfileTemplate");
            this.JobProfile.JobProfileId  = Guid.NewGuid().ToString();
            this.JobProfile.CanonicalName = this.CommonAction.RandomString(10).ToLowerInvariant();

            var socCode     = this.CommonAction.RandomString(5);
            var socCodeData = new SocCodeData()
            {
                SOCCode                 = socCode,
                Id                      = Guid.NewGuid().ToString(),
                UrlName                 = socCode.ToUpperInvariant(),
                Description             = "This an automated SOC code data record",
                ONetOccupationalCode    = this.CommonAction.RandomString(5),
                ApprenticeshipFramework = new List <ApprenticeshipFramework>()
                {
                    new ApprenticeshipFramework()
                    {
                        Id          = Guid.NewGuid().ToString(),
                        Description = "This is an automated apprenticeship framework",
                        Title       = "This is an automated apprenticeship framework title",
                        Url         = new Uri($"https://{this.CommonAction.RandomString(10)}.com/"),
                    },
                },
                ApprenticeshipStandards = new List <ApprenticeshipStandard>()
                {
                    new ApprenticeshipStandard()
                    {
                        Id          = Guid.NewGuid().ToString(),
                        Description = "This is an automated apprenticeship standard",
                        Title       = "This is an automated apprenticeship standard title",
                        Url         = new Uri($"https://{this.CommonAction.RandomString(10)}.com/"),
                    },
                },
            };

            var workingHoursDetail = new WorkingHoursDetail()
            {
                Id          = Guid.NewGuid().ToString(),
                Description = "default-description",
                Title       = "default-title",
                Url         = new Uri($"https://{this.CommonAction.RandomString(10)}.com/"),
            };

            var workingPattern = new WorkingPattern()
            {
                Id          = Guid.NewGuid().ToString(),
                Description = "default-description",
                Title       = "default-title",
                Url         = new Uri($"https://{this.CommonAction.RandomString(10)}.com/"),
            };

            var workingPatternDetails = new WorkingPatternDetail()
            {
                Id          = Guid.NewGuid().ToString(),
                Description = "default-description",
                Title       = "default-title",
                Url         = new Uri($"https://{this.CommonAction.RandomString(10)}.com/"),
            };

            this.JobProfile.SocCodeData = socCodeData;
            this.JobProfile.WorkingHoursDetails.Add(workingHoursDetail);
            this.JobProfile.WorkingPattern.Add(workingPattern);
            this.JobProfile.WorkingPatternDetails.Add(workingPatternDetails);

            // Send job profile to the service bus
            jobProfileMessageBody = this.CommonAction.ConvertObjectToByteArray(this.JobProfile);
            message = new MessageFactory().Create(this.JobProfile.JobProfileId, jobProfileMessageBody, "Published", "JobProfile");
            await this.ServiceBus.SendMessage(message).ConfigureAwait(false);

            await Task.Delay(10000).ConfigureAwait(false);
        }