public void GetBlockAsyncBlockNotInCacheQueriesRepositoryStoresBlockInCacheAndReturnsBlock_IX() { uint256 blockId = new uint256(2389704); Block repositoryBlock = new Block(); repositoryBlock.Header.Version = 1451; this.indexRepository.Setup(b => b.GetAsync(blockId)) .Returns(Task.FromResult(repositoryBlock)); var memoryCacheStub = new MemoryCacheStub(); this.indexStoreCache = new IndexStoreCache(this.indexRepository.Object, memoryCacheStub, DateTimeProvider.Default, this.loggerFactory); var result = this.indexStoreCache.GetBlockAsync(blockId); result.Wait(); Assert.Equal(blockId, memoryCacheStub.GetLastCreateCalled()); Assert.Equal(1451, result.Result.Header.Version); }
public void GetBlockByTrxAsyncBlockNotInCacheLookupInRepository_IX() { uint256 txId = new uint256(3252); uint256 blockId = new uint256(2389704); Block block = new Block(); block.Header.Version = 1451; var dict = new Dictionary <object, object>(); dict.Add(blockId, block); var memoryCacheStub = new MemoryCacheStub(dict); this.indexStoreCache = new IndexStoreCache(this.indexRepository.Object, memoryCacheStub, DateTimeProvider.Default, this.loggerFactory); this.indexRepository.Setup(b => b.GetTrxBlockIdAsync(txId)) .Returns(Task.FromResult(blockId)); var result = this.indexStoreCache.GetBlockByTrxAsync(txId); result.Wait(); Assert.Equal(1451, result.Result.Header.Version); Assert.Equal(txId, memoryCacheStub.GetLastCreateCalled()); }