public async Task GetHelpersByPostcode() { VolunteersForCacheGetter volunteersolunteersForCacheGetter = new VolunteersForCacheGetter(_repository.Object, _applicationConfig.Object); IEnumerable <CachedVolunteerDto> result = await volunteersolunteersForCacheGetter.GetAllVolunteersAsync(CancellationToken.None); // check batch sizes are calculated correctly _repository.Verify(x => x.GetVolunteersForCacheAsync(It.Is <int>(y => y == 100), It.Is <int>(y => y == 199)), Times.Once); _repository.Verify(x => x.GetVolunteersForCacheAsync(It.Is <int>(y => y == 200), It.Is <int>(y => y == 299)), Times.Once); _repository.Verify(x => x.GetVolunteersForCacheAsync(It.Is <int>(y => y == 100), It.Is <int>(y => y == 199)), Times.Once); _repository.Verify(x => x.GetVolunteersForCacheAsync(It.Is <int>(y => y == 200), It.Is <int>(y => y == 299)), Times.Once); Assert.AreEqual(2, result.Count()); Assert.AreEqual("NG1 1AA", result.FirstOrDefault(x => x.UserId == 1).Postcode); Assert.AreEqual(1.2, result.FirstOrDefault(x => x.UserId == 1).SupportRadiusMiles); Assert.AreEqual(1, result.FirstOrDefault(x => x.UserId == 1).Latitude); Assert.AreEqual(2, result.FirstOrDefault(x => x.UserId == 1).Longitude); Assert.AreEqual(VolunteerType.StreetChampion, result.FirstOrDefault(x => x.UserId == 1).VolunteerType); Assert.AreEqual(IsVerifiedType.IsVerified, result.FirstOrDefault(x => x.UserId == 1).IsVerifiedType); Assert.AreEqual("NG1 1AB", result.FirstOrDefault(x => x.UserId == 2).Postcode); Assert.AreEqual(2.4, result.FirstOrDefault(x => x.UserId == 2).SupportRadiusMiles); Assert.AreEqual(3, result.FirstOrDefault(x => x.UserId == 2).Latitude); Assert.AreEqual(4, result.FirstOrDefault(x => x.UserId == 2).Longitude); Assert.AreEqual(VolunteerType.Helper, result.FirstOrDefault(x => x.UserId == 2).VolunteerType); Assert.AreEqual(IsVerifiedType.IsVerified, result.FirstOrDefault(x => x.UserId == 2).IsVerifiedType); }
public async Task NoVolunteersInDbReturnsAnEmptyList() { _repository.Setup(x => x.GetAllDistinctVolunteerUserCount()).Returns(0); VolunteersForCacheGetter volunteersolunteersForCacheGetter = new VolunteersForCacheGetter(_repository.Object, _applicationConfig.Object); IEnumerable <CachedVolunteerDto> result = await volunteersolunteersForCacheGetter.GetAllVolunteersAsync(CancellationToken.None); Assert.AreEqual(0, result.Count()); }