Skip to content

API Reference

Aryeh Citron edited this page May 12, 2026 · 3 revisions

API Reference

Entry Points

InMemoryBigQuery

Static class for creating in-memory BigQuery instances.

Method Description
Create(projectId, datasetId?, configureDataset?) Creates a simple instance with optional dataset
Builder() Returns a builder for complex configurations

InMemoryBigQueryBuilder

Fluent builder for multi-dataset setups.

Method Description
WithProjectId(string) Sets the GCP project ID
AddDataset(string, Action<InMemoryDatasetBuilder>?) Adds a dataset
WithFaultInjector(Func<...>?) Sets the fault injector
Build() Builds and returns the result

InMemoryBigQueryResult

Result of creating an in-memory instance. Implements IDisposable.

Property Tier Description
Client 1 — Production-like Real BigQueryClient backed by in-memory store
Store 2 — Test setup Direct access to InMemoryDataStore
Handler 3 — Diagnostics The FakeBigQueryHandler (logs, fault injection)
Method Description
SetFaultInjector(Func<...>?) Sets or clears fault injection
CreateReadClient() Creates a BigQueryReadClient backed by the same in-memory store (Storage Read API)
Dispose() Cleans up resources

Data Store

InMemoryDataStore

Property Description
ProjectId The GCP project ID
Datasets ConcurrentDictionary<string, InMemoryDataset>
JsUdfEngine Optional IJsUdfEngine for JavaScript UDF execution
Method Description
ExportState() Returns JSON string of all datasets, tables, and rows
ExportStateToFile(string path) Exports state directly to a file
ImportState(string json) Replaces all data from a JSON string
ImportStateFromFile(string path) Imports state directly from a file
UseJsUdfs() Registers the Jint JavaScript engine for LANGUAGE js UDFs (requires InMemoryEmulator.BigQuery.JsUdfs package)

InMemoryDataset

Property Description
DatasetId Dataset identifier
Tables ConcurrentDictionary<string, InMemoryTable>
Description, FriendlyName, Location, Labels Metadata
CreationTime, LastModifiedTime, Etag Timestamps

InMemoryTable

Property Description
TableId Table identifier
Schema TableSchema — the column definitions
RowCount Number of rows
Description, FriendlyName, Labels Metadata
CreationTime, LastModifiedTime, Etag Timestamps

HTTP Layer

FakeBigQueryHandler

Extends HttpMessageHandler. Routes BigQuery REST API calls to the in-memory store.

Property Description
FaultInjector Optional delegate for simulating errors
RequestLog ConcurrentBag<string> of all requests
QueryLog ConcurrentBag<string> of all SQL queries

FakeBigQueryHttpClientFactory

Implements IHttpClientFactory for the Google API client pipeline.

DI Integration

ServiceCollectionExtensions

Method Description
UseInMemoryBigQuery(Action<InMemoryBigQueryOptions>?) Replaces BigQueryClient with in-memory

InMemoryBigQueryOptions

Property Description
ProjectId GCP project ID (default: "test-project")
Datasets List of datasets to create
OnClientCreated Callback after the client is created

Clone this wiki locally