public async Task GetAllStations_SetupsCache() { // arrange var fixture = new Fixture(); var repo = A.Fake <IStationRepository>(); var cache = A.Fake <ICacheProvider>(); var expected = fixture .CreateMany <Station>() .ToList(); A.CallTo(() => cache.GetOrSet( $"{nameof(StationRepositoryCachingDecorator)}|{nameof(StationRepositoryCachingDecorator.GetAllStations)}", A <Func <Task <IReadOnlyCollection <Station> > > > .Ignored)) .Returns(expected); // act var sut = new StationRepositoryCachingDecorator(repo, cache); var actual = await sut.GetAllStations() .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; }