public async Task GetAllStations_SetupsCache() { // arrange var fixture = new Fixture(); var service = A.Fake <IStationService>(); var cache = A.Fake <ICacheProvider>(); var query = fixture.Create <string>(); var expected = fixture.Create <(IReadOnlyCollection <Station>, IReadOnlyCollection <char>)>(); A.CallTo(() => cache.GetOrSet( $"{nameof(StationServiceCachingDecorator)}|{nameof(StationServiceCachingDecorator.Search)}|{query}", A <Func <Task <(IReadOnlyCollection <Station>, IReadOnlyCollection <char>)> > > .Ignored)) .Returns(expected); // act var sut = new StationServiceCachingDecorator(service, cache); var actual = await sut.Search(query) .ConfigureAwait(true); // assert actual.Should().BeEquivalentTo(expected); }
public StationScenariosSteps() { var options = new DbContextOptionsBuilder <Context>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; this.stationContext = new Context(options); var cacheProvider = new InMemoryCachingProvider(); var repository = new StationRepository(this.stationContext); var cachingRepository = new StationRepositoryCachingDecorator(repository, cacheProvider); var service = new StationService.StationService(cachingRepository); var cachingService = new StationServiceCachingDecorator(service, cacheProvider); this.stationService = cachingService; }