public void Run_WithPhoneCallOnSuccess_SavesPhoneCallAndIncrementsCallbackBookingQuotaNumberOfBookings()
        {
            var candidateId = Guid.NewGuid();
            var scheduledAt = DateTime.UtcNow.AddDays(3);
            var phoneCall   = new PhoneCall()
            {
                ScheduledAt = scheduledAt
            };

            _candidate.PhoneCall = phoneCall;
            var quota = new CallbackBookingQuota()
            {
                StartAt = scheduledAt, NumberOfBookings = 5, Quota = 10
            };

            _mockContext.Setup(m => m.GetRetryCount(null)).Returns(0);
            _mockCrm.Setup(mock => mock.Save(It.IsAny <Candidate>())).Callback <BaseModel>(c => c.Id = candidateId);
            _mockCrm.Setup(mock => mock.GetCallbackBookingQuota(scheduledAt)).Returns(quota);

            _job.Run(_candidate.SerializeChangeTracked(), null);

            phoneCall.CandidateId = candidateId.ToString();
            _mockCrm.Verify(mock => mock.Save(It.Is <PhoneCall>(p => IsMatch(phoneCall, p))), Times.Once);
            _mockCrm.Verify(mock => mock.Save(It.Is <CallbackBookingQuota>(q => IsMatch(quota, q))), Times.Once);
            quota.NumberOfBookings.Should().Be(6);
            _metrics.HangfireJobQueueDuration.WithLabels(new[] { "UpsertCandidateJob" }).Count.Should().Be(1);
        }
Example #2
0
        private static IEnumerable <CallbackBookingQuota> MockQuotas()
        {
            var quota1 = new CallbackBookingQuota()
            {
                Id = Guid.NewGuid()
            };

            return(new [] { quota1 });
        }
        public void IsAvailable_ReturnsCorrectly(int numberOfBookings, int quota, bool expected)
        {
            var callbackBookingQuota = new CallbackBookingQuota()
            {
                NumberOfBookings = numberOfBookings, Quota = quota
            };

            callbackBookingQuota.IsAvailable.Should().Be(expected);
        }
Example #4
0
        private static bool VerifyDay(CallbackBookingQuota quota)
        {
            var localStartAt = TimeZoneInfo.ConvertTimeFromUtc(quota.StartAt, TimeZoneInfo.Local);

            return(quota.Day == localStartAt.ToLongDateString());
        }
Example #5
0
        private static bool VerifyTimeSlot(CallbackBookingQuota quota)
        {
            var localEndAt = TimeZoneInfo.ConvertTimeFromUtc(quota.EndAt, TimeZoneInfo.Local);

            return(quota.TimeSlot == $"{localEndAt.ToShortTimeString()} - {localEndAt.ToShortTimeString()}");
        }