예제 #1
0
        public async Task HasLearnerRecordsShouldReturnFalseIfCacheIsEmpty()
        {
            dataCache = new Mock <IActorDataCache <List <ApprenticeshipModel> > >();
            dataCache.
            Setup(o => o.IsEmpty(It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(true));
            ukprnCache.
            Setup(o => o.IsEmpty(It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(true));
            var dataLockLearnerCache = new DataLockLearnerCache(dataCache.Object, ukprnCache.Object);
            var actual = await dataLockLearnerCache.UkprnExists(1234).ConfigureAwait(false);

            actual.Should().BeFalse();
        }
예제 #2
0
        public async Task ShouldReturnDuplicateApprenticeshipsIfCacheIsNotEmpty()
        {
            var duplicateApprenticeships = new List <ApprenticeshipModel>
            {
                new ApprenticeshipModel
                {
                    Ukprn     = 100,
                    AccountId = 200
                }
            };
            var cacheApprenticeships = new ConditionalValue <List <ApprenticeshipModel> >(true, duplicateApprenticeships);

            dataCache = new Mock <IActorDataCache <List <ApprenticeshipModel> > >();
            dataCache.Setup(o => o.TryGet(It.IsAny <string>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(cacheApprenticeships));

            var dataLockLearnerCache = new DataLockLearnerCache(dataCache.Object, ukprnCache.Object);
            var actual = await dataLockLearnerCache.GetDuplicateApprenticeships().ConfigureAwait(false);

            actual.Should().NotBeNull();
            actual.Should().HaveCount(1);
        }