Beispiel #1
0
        public async Task Should_Record_Http_Request_When_Cassette_Is_Activated()
        {
            var depA = await _geoApi2.GetDepartements("11");

            byte[] cassetteA = await _cache2.GetAsync(KeyGetRegion11Deps);

            cassetteA.Should().NotBeNull("The cassette should have been cached.");

            await WaitHalftTheDurationOfTheExpirationTime();

            var depB = await _geoApi2.GetDepartements("11");

            byte[] cassetteB = await _cache2.GetAsync(KeyGetRegion11Deps);

            cassetteB.Should().NotBeNull("The cassette should still be in cache, because the expiration time has not been reached.");
            depA.Should().BeEquivalentTo(depB, "The 2 departments should be the same.");
            cassetteA.Should().BeEquivalentTo(cassetteB, "The 2 cassettes should be the same.");

            await WaitHalftTheDurationOfTheExpirationTime();

            (await _cache2.GetAsync(KeyGetRegion11Deps)).Should().BeNull("The cache should be empty, because the expiration time has been reached.");
        }
Beispiel #2
0
        public async Task Should_Not_Record_Anything_When_Cassette_Is_Not_Activated()
        {
            await _geoApi1.GetDepartements("11");

            (await _cache1.GetAsync(KeyGetRegion11Deps)).Should().BeNull("The cache should be empty, because Cassette is not activated.");
        }
Beispiel #3
0
 public async Task <ActionResult <IEnumerable <Departement> > > GetDepartements(string code)
 {
     return(await _geoApi.GetDepartements(code));
 }