Skip to content

samblackburn/RecordReplay

Repository files navigation

RecordReplay

Make any integration test fast!

What is Record Replay?

This repo is a demonstration of a caching technique for slow dependencies of a system under test. The idea is to create a RR cache of the dependency, which will spin up the actual dependency if it receives a call it hasn't seen before. However, as long as it receives calls it has seen before, it will return whatever was returned the first time around.

Stateful objects

The technique is intended to memoize highly stateful objects such as databases, so it is assumed that all calls modify the state of the object.

Example

var kvs = new InMemoryKeyValueStore(); // In reality you'd want a persisted store
var foo = RecordReplay<IFoo>.Create(kvs, () => new SlowFoo());
foo.Append("HELLO"); // Our SlowFoo will be created at this point
var output = foo.Append("GOODBYE");

var foo2 = RecordReplay<IFoo>.Create(kvs, () => new SlowFoo());
foo2.Append("HELLO"); // At this point another SlowFoo won't be created, and the cache will be used
var output = foo2.Append("GOODBYE");

About

Make any integration test fast!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages